cant install balena cli on wsl (moved from websdr ticket)

cant install balena cli in windows 10 wsl ubuntu

npm WARN addRemoteGit Error: Command failed: git config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:275:12)
npm WARN addRemoteGit at emitTwo (events.js:126:13)
npm WARN addRemoteGit at ChildProcess.emit (events.js:214:7)
npm WARN addRemoteGit at maybeClose (internal/child_process.js:925:16)
npm WARN addRemoteGit at Socket.stream.socket.on (internal/child_process.js:346:11)
npm WARN addRemoteGit at emitOne (events.js:116:13)
npm WARN addRemoteGit at Socket.emit (events.js:211:7)
npm WARN addRemoteGit at Pipe._handle.close [as _onclose] (net.js:567:12)
npm WARN addRemoteGit balena-io-modules/unbzip2-stream#942fc218013c14adab01cf693b0500cf6ac83193 resetting remote /root/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6 because of error: { Error: Command failed: git config --get remote.origin.url

Hi, can you tell us what steps did you take that led to this error? Also can you try this approach?

i just did

npm install typescript
npm install balena-cli

but will try your undocumented nvm trick instead

Last step is to run npm install balena-cli -g --production --unsafe-perm which has -g flag meaning it will be installed globally.

trying

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

already getting 100’s of warnings

npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-301c3949/lib/copy/copy.js’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-8e55f272/lib/empty/index.js’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/file.js’
npm WARN tar ENOENT: no such file or directory, lstat ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/fixtures’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-301c3949/lib/copy/index.js’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/index.js’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/diff-f9d11c18/release-notes.md’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/link.js’
npm WARN tar ENOENT: no such file or directory, lstat ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/fixtures’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/symlink-paths.js’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/unzip-stream-2ca75c3e/.nyc_output/d5d10d528489eedb54307d3df611eada.json’
npm WARN tar ENOENT: no such file or directory, lstat ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/fixtures’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/symlink-type.js’
npm WARN tar ENOENT: no such file or directory, lstat ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/bluebird-bbe3f7dc/js/release’
npm WARN tar ENOENT: no such file or directory, open ‘/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/fs-extra-60951c61/lib/ensure/symlink.js’

and now AN ERROR

npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/balena-io-modules/unbzip2-stream.git
npm ERR!
npm ERR! fatal: cannot come back to cwd: Permission denied
npm ERR!
npm ERR! exited with error code: 128

please advise when you have properly tested balena on wsl until then i will use my xubuntu vm

I’ll ping balena cli maintainer and we’ll get back to you when we have news.

1 Like

Hi, we tested the npm installation in a fresh WSL/Ubuntu installation, and did not encounter any errors. Can you tell us more?

Which WSL version you are using
node version
npm version

Also can you try standalone on wsl? https://github.com/balena-io/balena-cli/releases/tag/v11.29.4

ok will retry

now getting

npm WARN ts-node@8.6.2 requires a peer of typescript@>=2.7 but none was installed.
npm ERR! Linux 4.4.0-18362-Microsoft
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "balena-cli" "-g" "--production" "--unsafe-perm"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/cdarra/npm-debug.log
cdarra@DESKTOP-AEK3BDI:~$

switched to root and get

npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/all.spec.ts'
npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-59874da8/src/compose.ts'
npm WARN tar ENOENT: no such file or directory, lstat '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/fixtures'
npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/uglify-to-browserify-a2f01b42/test/index.js'
npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-59874da8/src/errors.ts'
npm WARN tar ENOENT: no such file or directory, lstat '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-474f0b8e/test/fixtures'
npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/.staging/resin-compose-parse-59874da8/src/index.ts'

sorry i cant waste any more time testing this for you

Thank you for reporting this.
Unfortunately we were not able to duplicate your error on our test system, so we will not be able to get much further without your input.
I will forward your last logs to the maintainer to see if they contain any insights for him.

@osde8info, thank you for sharing the errors and feedback. I have just updated the “official” installation instructions to emphasise the recommendation of selecting the standalone zip package for Linux when using the Windows Subsystem for Linux. The main advantage of the standalone zip package is that it avoids the need for installing Node/npm/nvm and compiling source code, which is time consuming, somewhat error prone, and requires several dependencies to be pre-installed.

I gather that all the errors you shared were related to the NPM installation, which we only recommend to Node.js developers who are specifically interested in installing the CLI with npm, such as source code contributors to the CLI.

You can find out more about the different installation options at: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md

I’ve just successfully tested both the standalone zip package (Linux) and the NPM installation on the Windows Subsystem for Linux (WSL 1, not WSL 2).

What follows regards the NPM installation and the errors you shared, but I don’t really recommend pursuing it unless you have a specific reason to. On WSL, I recommend using the standalone zip package for Linux instead.


Looking at the error messages you shared for the NPM installation option, a few of them mention “Permission denied”. What comes to mind is that some installation steps (including the nvm installation) may have been performed by the root user, and others by a non-root user (cdarra). I have also noticed a mix of “nvm Node” and “system Node”:

“nvm Node”:

npm WARN tar ENOENT: no such file or directory, open '/root/.nvm/versions/node/v13.11.0/lib/node_modules/...'

“System Node:” (i.e. a Node installation using something like sudo apt-get install node)

npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "balena-cli" "-g" "--production" "--unsafe-perm"
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'

With WSL / Ubuntu, avoid using the “system Node” if possible, as pointed out in the instructions for the NPM installation option.

In my NPM installation test on WSL, I chose to use nvm and installed it as a non-root user. Note how the command which node below points to "/home/paulo/.nvm/..." instead of "/root/.nvm/..." as in some of the logs you shared:

paulo@DESKTOP-3021L0B:~$ nvm use 13.11.0
Now using node v13.11.0 (npm v6.13.7)

paulo@DESKTOP-3021L0B:~$ which node
/home/paulo/.nvm/versions/node/v13.11.0/bin/node

paulo@DESKTOP-3021L0B:~$ node --version
v13.11.0

paulo@DESKTOP-3021L0B:~$ npm install balena-cli -g --production
...

paulo@DESKTOP-3021L0B:~$ which balena
/home/paulo/.nvm/versions/node/v13.11.0/bin/balena

paulo@DESKTOP-3021L0B:~$ balena version -a
balena-cli version "11.29.5"
Node.js version "13.11.0"

Above I used Node version 13.11.0 to match your error report, but the balena CLI has been mostly tested with Node versions 8, 10 and 12 (not 13), as mentioned in the installation instructions.

Also, in my WSL installation, I did not install Node using apt-get, so /usr/bin/node does not exist, which helps avoid confusion:

paulo@DESKTOP-3021L0B:~$ /usr/bin/node --version
No such file or directory

If you had a specific reason to install nvm for the root user, then run the npm install command as the root user as well. Otherwise, I recommend installing both nvm and the CLI as a non-root user. You can remove the nvm installation for the root user with the commands:

nvm unload
rm -rf /root/.nvm

Then, as a non-root user, without using sudo, install nvm and some version of Node (e.g. nvm install 10.18.1, to give you a version number) as per instructions in nvm’s website.

The balena-cli NPM installation option also requires additional dependencies to be installed. The installation instructions mention the following line for the Windows Subsystem for Linux:

sudo apt-get install -y python git make g++

Then finally, as the same ordinary user used to install nvm (without using sudo), install balena-cli:

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

The instructions for the NPM installation option include a note regarding the --unsafe-perm option. In my test on WSL with nvm as a non-root user, the --unsafe-perm option was not required, and did not appear to make any difference.


Some final notes regarding WSL support:

  • The most common CLI commands should work well on WSL, but there are some commands that require some Linux features not provided by WSL. You can use/install both the CLI for Windows (to use with PowerShell or in a cmd.exe prompt) and the standalone zip package for Linux (to use in a WSL prompt) at the same time, which together should give you a wider coverage of supported commands.
  • Everything I mentioned in this post regards WSL 1. The balena CLI team is yet to test WSL 2, so I cannot yet comment on it. :slight_smile:

thanks will give it another try

btw NODE/NPM is a complete mess (but thats not your fault)

ok uninstalled nvm and rerunning npm install balena-cli --production

now getting

npm WARN addRemoteGit Error: Command failed: git config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:275:12)
npm WARN addRemoteGit at emitTwo (events.js:126:13)
npm WARN addRemoteGit at ChildProcess.emit (events.js:214:7)
npm WARN addRemoteGit at maybeClose (internal/child_process.js:925:16)
npm WARN addRemoteGit at Socket.stream.socket.on (internal/child_process.js:346:11)
npm WARN addRemoteGit at emitOne (events.js:116:13)
npm WARN addRemoteGit at Socket.emit (events.js:211:7)
npm WARN addRemoteGit at Pipe._handle.close [as _onclose] (net.js:567:12)
npm WARN addRemoteGit balena-io-modules/unbzip2-stream#942fc218013c14adab01cf693b0500cf6ac83193 resetting remote /home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6 because of error: { Error: Command failed: git config --get remote.origin.url
npm WARN addRemoteGit
npm WARN addRemoteGit at ChildProcess.exithandler (child_process.js:275:12)
npm WARN addRemoteGit at emitTwo (events.js:126:13)
npm WARN addRemoteGit at ChildProcess.emit (events.js:214:7)
npm WARN addRemoteGit at maybeClose (internal/child_process.js:925:16)
npm WARN addRemoteGit at Socket.stream.socket.on (internal/child_process.js:346:11)
npm WARN addRemoteGit at emitOne (events.js:116:13)
npm WARN addRemoteGit at Socket.emit (events.js:211:7)
npm WARN addRemoteGit at Pipe._handle.close [as _onclose] (net.js:567:12)
npm WARN addRemoteGit killed: false,
npm WARN addRemoteGit code: 1,
npm WARN addRemoteGit signal: null,
npm WARN addRemoteGit cmd: ‘git config --get remote.origin.url’ }

and

npm ERR! git fetch -a origin (https://github.com/resin-io-modules/resin-discoverable-services.git) fatal: unable to access ‘https://github.com/resin-io-modules/resin-discoverable-services.git/’: Failed to connect to github.com port 443: Connection refused
npm ERR! git fetch -a origin (https://github.com/resin-io/bonjour.git) fatal: unable to access ‘https://github.com/resin-io/bonjour.git/’: Failed to connect to github.com port 443: Connection refused
npm ERR! git fetch -a origin (https://github.com/resin-io-modules/multicast-dns.git) fatal: unable to access ‘https://github.com/resin-io-modules/multicast-dns.git/’: Failed to connect to github.com port 443: Connection refused
npm ERR! git clone --template=/home/cdarra/.npm/_git-remotes/_templates --mirror git://github.com/balena-io-modules/unbzip2-stream.git /home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6: Cloning into bare repository ‘/home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6’…
npm ERR! git clone --template=/home/cdarra/.npm/_git-remotes/_templates --mirror git://github.com/balena-io-modules/unbzip2-stream.git /home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6: fatal: unable to connect to github.com:
npm ERR! git clone --template=/home/cdarra/.npm/_git-remotes/_templates --mirror git://github.com/balena-io-modules/unbzip2-stream.git /home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6: github.com[0: 140.82.118.4]: errno=Resource temporarily unavailable
npm ERR! git clone --template=/home/cdarra/.npm/_git-remotes/_templates --mirror git://github.com/balena-io-modules/unbzip2-stream.git /home/cdarra/.npm/_git-remotes/git-github-com-balena-io-modules-unbzip2-stream-git-942fc218013c14adab01cf693b0500cf6ac83193-841db6b6: github.com[1: 64:ff9b::8c52:7604]: errno=Network is unreachable