Cannot npm install -g @openzeppelin/cli@2.6 on macOS Catalina 10.15.1

Hi,
I ran into some problem when installing on maOS Catalina 10.15.1.
Env:
node --version: v10.17.0
npm --version: 6.12.1

  1. I must use sudo, else it fails.
  2. I can only npm install @openzeppelin/cli@2.6 locally into a project.
  3. I tried sudo installing globally - this removed my previous global npm @openzeppelin/cli package, but did not replace it with the 2.6 version. Instead it, I get the following error:

Any idea how I can install 2.6 globally on macOS Catalina?

Also, I was not able to reinstall the previous version, due to a new error that wasnt there before I tried to upgrade:

=====

UPDATE: I got the local version to work, and realized I just had to prefix the commands with npx.

1 Like

Hi @gitpusha,

Sorry to hear that you are running into permission issues when installing.

Using sudo with npm is highly discouraged, so I recommend resolving the permission issues, either with a node version manager or change npm's default directory:

https://github.com/OpenZeppelin/openzeppelin-sdk/blob/master/README.md
If you get an EACCESS permission denied error while installing, please refer to the npm documentation on global installs permission errors. Alternatively, you may run sudo npm install --unsafe-perm --global @openzeppelin/cli , but this is highly discouraged, and you should rather either use a node version manager or manually change npm's default directory.

I use nvm as part of my setup (What is your smart contract development environment setup?)

I am a big fan of Installing packages locally rather than globally (npx). Though I was creating so many OpenZeppelin SDK based projects that I installed @openzeppelin/cli globally.

1 Like

Hi @gitpusha,

Just checking if you were able to resolve installing globally?

1 Like

Hi @abcoathup - I have not used nvm yet, but it always reappears the more I look around in the npm/node ecosystem. So far, I have used homebrew on macOS to manage my packages. I will give nvm a try asap. For now I am happy continuing my work with the local version and running npx.

1 Like

Hi @abcoathup.
I finally installed nvm and use it now. And success, I was able to install the @openzeppelin/cli into my global npm store for my nvm node --version 12.13.0.

It also now works with nvm node --version 10.17.0

So the root cause of all evil seems to have been my macOS brew-only node install.

I now have nvm installed with brew and node with nvm. Probably the next best setup would be to clean install nvm (no brew) too.

But it works great for now with brewed nvm.

This was a good guide: https://www.chrisjmendez.com/2018/02/07/install/

HOWEVER: there is a bug I encounter with running oz compile on nvm node -v 12.13.0 ONLY - I do not have the bug on node -v 10.17.0.

See: Oz compile fails with spawnSync /bin/sh ENOBUFS

Thank you!

1 Like

Hi @gitpusha,

Great to hear that you can install OpenZeppelin CLI globally with nvm.

Shame that there is a compilation issue with node 12. Will see what I can find out.

1 Like

It did not work, getting the same error.

1 Like

Hi @pkr,

Sorry that the workaround didn’t work for you. I discourage using sudo with npm, so am not keen on it.

I recommend using nvm or installing locally.
Alternatively, manually change npm’s default directory.
The following is the npm recommendations:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Hmmm some reason it doesn’t like to load nvm

I followed this guide

if this data point is helpful

node -v
v10.16.2

npm -v
6.12.1

npx -v
10.2.0

nvm -v
-bash: nvm: command not found
1 Like

Hi @pkr,

From the nvm documentation: https://github.com/nvm-sh/nvm#install--update-script it suggests some things to try:

Note: On OS X, if you get nvm: command not found after running the install script, one of the following might be the reason:

  • Your system may not have a .bash_profile file where the command is set up. Create one with touch ~/.bash_profile and run the install script again
  • You might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.

If the above doesn't fix the problem, you may try the following:

  • Open your .bash_profile (or ~/.zshrc , ~/.profile , or ~/.bashrc ) and add the following line of code: source ~/<your_profile_file> . E.g. source ~/.bashrc or source ~/.zshrc .
  • If the above don't work, try adding the snippet from the install section that finds the correct nvm directory and loads nvm, to your profile ( ~/.bash_profile , ~/.zshrc , ~/.profile , or ~/.bashrc ).
  • For more information about this issue and possible workarounds, please refer here

Tx @abcoathup I have tried all the options and still not working.

Here is what i have in all my .profiles (.bashrc, .bash_profile, .zshrc, .profile)

export NVM_DIR="$HOME/.nvm"

[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm

[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm 
1 Like

Hi @pkr,

Sorry that you are still having trouble with the environment.
Have you also been through this issue as there appear to be a couple of things you could try? https://github.com/nvm-sh/nvm/issues/576

For now I suggest that you could install OpenZeppelin SDK locally (rather than globally) and use via npx, so that you can start using it.

what is the command to install it locally as this is failing

npm install @openzeppelin/cli@2.6

I tried this npx @openzeppelin/cli@2.6 and got this error

Error

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/pk/.npm/_npx/9590/lib/node_modules/@openzeppelin/cli/node_modules/solc-wrapper/node_modules/keccak
gyp ERR! node -v v10.16.2
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pk/.npm/_logs/2019-11-21T04_55_38_098Z-debug.log
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npx/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npx/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/pk/.npm/_npx/9590/lib/node_modules/@openzeppelin/cli/node_modules/sha3
gyp ERR! node -v v10.16.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3@1.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pk/.npm/_logs/2019-11-21T04_55_46_186Z-debug.log
Install for @openzeppelin/cli@2.6 failed with code 1
1 Like

OKay managed to install node using nvm

~ ❯ nvm ls                                                                                                  took 11s at 16:12:36
->      v13.1.0
         system
default -> 13.1.0 (-> v13.1.0)
node -> stable (-> v13.1.0) (default)
stable -> 13.1 (-> v13.1.0) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.16.2 (-> N/A)
lts/dubnium -> v10.17.0 (-> N/A)
lts/erbium -> v12.13.1 (-> N/A)
1 Like

I am getting build error now for this command npx npm install @openzeppelin/cli

Error

npx npm install @openzeppelin/cli                                      at 16:42:20
npm WARN deprecated truffle-config@1.1.16: WARNING: This package has been renamed to @truffle/config.
npm WARN deprecated truffle-provider@0.1.16: WARNING: This package has been renamed to @truffle/provider.
npm WARN deprecated truffle-interface-adapter@0.2.5: WARNING: This package has been renamed to @truffle/interface-adapter.

> sha3@1.2.3 install /Users/pk/Documents/code/abstract/abstract-st/node_modules/sha3
> node-gyp rebuild

  CXX(target) Release/obj.target/sha3/src/addon.o
In file included from ../src/addon.cpp:9:
In file included from ../src/KeccakNISTInterface.h:17:
../src/KeccakSponge.h:23:9: warning: 'ALIGN' macro redefined [-Wmacro-redefined]
#define ALIGN __attribute__ ((aligned(32)))
        ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/i386/param.h:83:9: note:
      previous definition is here
#define ALIGN(p)        __DARWIN_ALIGN(p)
        ^
../src/addon.cpp:83:11: error: no matching member function for call to 'Set'
                target->Set(className, f);
                ~~~~~~~~^~~
/Users/pk/Library/Caches/node-gyp/13.1.0/include/node/v8.h:3424:37: note: candidate function not viable: requires 3 arguments, but
      2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context,
                                    ^
/Users/pk/Library/Caches/node-gyp/13.1.0/include/node/v8.h:3427:37: note: candidate function not viable: requires 3 arguments, but
      2 were provided
  V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index,
                                    ^
1 warning and 1 error generated.
make: *** [Release/obj.target/sha3/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/pk/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command "/Users/pk/.nvm/versions/node/v13.1.0/bin/node" "/Users/pk/.nvm/versions/node/v13.1.0/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/pk/Documents/code/abstract/abstract-st/node_modules/sha3
gyp ERR! node -v v13.1.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3@1.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3@1.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/pk/.npm/_logs/2019-11-21T05_42_44_953Z-debug.log
1 Like

Hi @pkr,

To install locally in a project you can use:
npm install @openzeppelin/cli
You can then run using
npx oz [command]

This looks like an issue with node 13. I will create an issue.
I use node v10.16.0