ERROR: npm install balena-cli -g --production --unsafe-perm

Hello.

root@nodejs:~# npm install balena-cli -g --production --unsafe-perm
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/resin-io-modules/node-web-streams.git
npm ERR!
npm ERR! fatal: cannot come back to cwd: Permission denied
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-02T06_49_42_894Z-debug.log

But if i do in cmd:

root@nodejs:~# /usr/bin/git ls-remote -h -t https://github.com/balena-io-modules/node-web-streams.git
46f98300b69090bde3f6b4983877ccfe283a892c refs/heads/emit-errors
5af50c2e91502d577178d7bd85f9e8b7408ea6e7 refs/heads/master
b8b7ab482e71145a03da7e03ac85888395da21f2 refs/tags/v0.2.0
e444ffd68cc05f68c48147e2c07fbcbd080f304d refs/tags/v0.2.1

When https instead ssh, it is works! I think, it is because some changes in github.

Please fix it =) Thank you!

Thanks for reporting this. We will look into this right away, would you mind sharing the OS version you tried this on?

root@nodejs:/home/sergg# npm -v
6.9.0
root@nodejs:/home/sergg# node -v
v10.16.0
root@nodejs:/home/sergg# uname -a
Linux nodejs 4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Recently this paragraph was added to the CLI installation instructions:

https://github.com/balena-io/balena-cli/blob/master/INSTALL.md

On some Linux distributions like Ubuntu, users often report permission or otherwise mysterious errors when using the system Node / npm packages installed via “apt-get”. We suggest using nvm instead. Check this sample Dockerfile for installing the CLI on an Ubuntu Docker image: Dockerfile for "npm install balena-cli" on Ubuntu Bionic · GitHub

Would you be able to try using nvm to install node, as suggested in the Gist link above? (I’ve just tested it, and it worked for me.)

Regarding the point that https works whereas ssh fails for the GitHub repo URL, so far I couldn’t reproduce it, and it sounds strange that it should make a difference, because resin-io-modules/node-web-streams is a public repo and I believe that GitHub offers access to any public repos via either ssh or https. I imagine that the Dockerfile example given above would have failed if the ssh issue was reproducible.

Also, as the CLI install instructions point out these days, the standalone zip installer may be more convenient (easier and faster to install) and less error prone, as it avoids the need for source code compilation and any npm installation permission errors.

Let us know how you get on.

Thank you for investigation. I installed from release.