Balena-cli running on Windows 10 - Is WSL supported?

Hi,

New to Balena and trying to get everything up and running. I’ve been following the guide: https://www.balena.io/open/docs/getting-started/ however when I try to install the balena-cli I constantly get errors. I’ve tried via windows command prompt and Windows Subsytem for Linux on Ubuntu 18.4.

I’ve also seen people use: sudo npm -g i balena-cli but I still get the same error:

npm WARN deprecated graceful-fs@3.0.11: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
/usr/local/bin/balena -> /usr/local/lib/node_modules/balena-cli/bin/balena

> husky@1.3.1 install /usr/local/lib/node_modules/balena-cli/node_modules/husky
> node husky install

husky > setting up git hooks
Can't find .git, skipping Git hooks installation.
Please check that you're in a cloned repository or run 'git init' to create an empty Git repository and reinstall husky.

> ext2fs@1.0.27 install /usr/local/lib/node_modules/balena-cli/node_modules/ext2fs
> prebuild-install || node-gyp rebuild


> mountutils@1.3.17 install /usr/local/lib/node_modules/balena-cli/node_modules/mountutils
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=8.10.0 runtime=node arch=x64 platform=linux)
make: Entering directory '/usr/local/lib/node_modules/balena-cli/node_modules/mountutils/build'
  CXX(target) Release/obj.target/MountUtils/src/mountutils.o
  CXX(target) Release/obj.target/MountUtils/src/worker-unmount.o
  CXX(target) Release/obj.target/MountUtils/src/worker-eject.o
  CXX(target) Release/obj.target/MountUtils/src/linux/functions.o
../src/linux/functions.cpp: In function ‘MOUNTUTILS_RESULT unmount_disk(const char*)’:
../src/linux/functions.cpp:98:21: warning: unused variable ‘result_code’ [-Wunused-variable]
   MOUNTUTILS_RESULT result_code = MOUNTUTILS_SUCCESS;
                     ^~~~~~~~~~~
  SOLINK_MODULE(target) Release/obj.target/MountUtils.node
  COPY Release/MountUtils.node
make: Leaving directory '/usr/local/lib/node_modules/balena-cli/node_modules/mountutils/build'

> drivelist@6.4.6 install /usr/local/lib/node_modules/balena-cli/node_modules/drivelist
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=8.10.0 runtime=node arch=x64 platform=linux)
make: Entering directory '/usr/local/lib/node_modules/balena-cli/node_modules/drivelist/build'
  CXX(target) Release/obj.target/drivelist/src/drivelist.o
  CXX(target) Release/obj.target/drivelist/src/device-descriptor.o
  CXX(target) Release/obj.target/drivelist/src/linux/list.o
  SOLINK_MODULE(target) Release/obj.target/drivelist.node
  COPY Release/drivelist.node
make: Leaving directory '/usr/local/lib/node_modules/balena-cli/node_modules/drivelist/build'

> xxhash@0.2.4 install /usr/local/lib/node_modules/balena-cli/node_modules/xxhash
> node-gyp rebuild

make: Entering directory '/usr/local/lib/node_modules/balena-cli/node_modules/xxhash/build'
  CXX(target) Release/obj.target/hash/src/hash.o
  SOLINK_MODULE(target) Release/obj.target/hash.node
  COPY Release/hash.node
make: Leaving directory '/usr/local/lib/node_modules/balena-cli/node_modules/xxhash/build'

> usb@1.3.5 install /usr/local/lib/node_modules/balena-cli/node_modules/usb
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/thundron/node-usb/releases/download/1.3.5/usb_bindings-v1.3.5-node-v57-linux-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for usb@1.3.5 and node@8.10.0 (node-v57 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory '/usr/local/lib/node_modules/balena-cli/node_modules/usb/build'
make: *** No rule to make target 'Release/obj.target/libusb/libusb/libusb/core.o', needed by 'Release/obj.target/usb.a'.  Stop.
make: Leaving directory '/usr/local/lib/node_modules/balena-cli/node_modules/usb/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.4.0-17763-Microsoft
gyp ERR! command "/usr/bin/node" "/usr/share/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding" "--napi_version=1" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
gyp ERR! cwd /usr/local/lib/node_modules/balena-cli/node_modules/usb
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/share/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build
--module=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/balena-cli/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.4.0-17763-Microsoft
node-pre-gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/balena-cli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/balena-cli/node_modules/usb
node-pre-gyp ERR! node -v v8.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/bin/node /usr/share/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/usr/local/lib/node_modules/balena-cli/node_modules/usb/src/binding --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)
/usr/local/lib
└── (empty)

npm WARN optional Skipping failed optional dependency /balena-cli/removedrive:
npm WARN notsup Not compatible with your operating system or architecture: removedrive@1.1.2
npm WARN optional Skipping failed optional dependency /balena-cli/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.8
npm WARN optional Skipping failed optional dependency /balena-cli/denymount/macmount:
npm WARN notsup Not compatible with your operating system or architecture: macmount@1.0.0
npm WARN optional Skipping failed optional dependency /balena-cli/etcher-sdk/winusb-driver-generator:
npm WARN notsup Not compatible with your operating system or architecture: winusb-driver-generator@1.2.4
npm WARN resin-register-device@5.0.0 requires a peer of resin-request@^9.0.2 but none was installed.
npm WARN ts-node@8.1.0 requires a peer of typescript@>=2.0 but none was installed.
npm ERR! Linux 4.4.0-17763-Microsoft
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "-g" "i" "balena-cli"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! usb@1.3.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the usb@1.3.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the usb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs usb
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls usb
npm ERR! There is likely additional logging output above.

Can anyone suggest any alternatives?
I’m just trying it in an Ubuntu VM but ideally I need this via WSL

Thanks

Hi @mjjames,

First off, I highly recommend watching our tutorial on how to properly install the CLI on a Windows machine here. Specifically, this video will show you how to perform a standalone install, which I suspect will allow you to use the CLI. Please let us know how that works for you!

Yeah, so using standalone does work, I found it via the git hub pages, I’m not a fan of Videos so prefer to read and apply knowledge :smiley:

Worth noting that the NPM way didn’t even work on my Ubuntu install, the Open-Balena documentation seems to indicate NPM is preffered not standalone but am I correct is saying that this is no longer the case and that the Open-Balena documentation is out of date?

Hey @mjjames,

We prefer people to use NPM whenever possible, as NPM will handle updates and other goodies for you, while you are more on your own when using the standalone package.

That might change in the future as we make the standalone package more feature-full though!

Hi jviotti,

this is what I thought. Any ideas on why even on Ubuntu I’m hitting the above error?
I’m assuming I’m missing a dependency that the script doesn’t check for?

I’m fairly confident its to do with node-usb as 1.3.5 cant be downloaded and then its not trying a newer version or to manually build it.

Is there a dependencies script available to ensure libusb and udev etc is installed?

Hi @mjjames and @jviotti,

I’m experiencing the same issue on Ubuntu 18.04.1 (not Windows Subsystem for Linux). Like you said @mjjames, the issue seems to occur while trying to build the node-usb module. This issue can be reproduced independently from balena-cli by cloning and installing the node-usb module directly:

$ git clone https://github.com/balena-io/node-usb && cd node-usb
$ npm install
> usb@1.3.5 install /home/rob/devel/node-usb
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(404): https://github.com/thundron/node-usb/releases/download/1.3.5/usb_bindings-v1.3.5-node-v57-linux-x64.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for usb@1.3.5 and node@8.10.0 (node-v57 ABI, glibc) (falling back to source compile with node-gyp) 
make: Entering directory '/home/rob/devel/node-usb/build'
make: *** No rule to make target 'Release/obj.target/libusb/libusb/libusb/core.o', needed by 'Release/obj.target/usb.a'.  Stop.
make: Leaving directory '/home/rob/devel/node-usb/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Linux 4.15.0-no-lpm+
gyp ERR! command "/usr/bin/node" "/usr/share/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/rob/devel/node-usb/src/binding/usb_bindings.node" "--module_name=usb_bindings" "--module_path=/home/rob/devel/node-usb/src/binding" "--napi_version=1" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"
gyp ERR! cwd /home/rob/devel/node-usb
gyp ERR! node -v v8.10.0
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/share/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/rob/devel/node-usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/rob/devel/node-usb/src/binding --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/home/rob/devel/node-usb/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Linux 4.15.0-no-lpm+
node-pre-gyp ERR! command "/usr/bin/node" "/home/rob/devel/node-usb/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/rob/devel/node-usb
node-pre-gyp ERR! node -v v8.10.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/bin/node /usr/share/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/rob/devel/node-usb/src/binding/usb_bindings.node --module_name=usb_bindings --module_path=/home/rob/devel/node-usb/src/binding --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)

npm ERR! Linux 4.15.0-no-lpm+
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! usb@1.3.5 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the usb@1.3.5 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the usb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs usb
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls usb
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/rob/devel/node-usb/npm-debug.log

The “No rule to make target ‘Release/obj.target/libusb/libusb/libusb/core.o …’” error seems to be the real issue. I experience the same problem by running make libusb or even just make from the ./build directory where gyp has autogenerated the Makefile. I also tried to clone and install https://github.com/thundron/node-usb, the repository from which balena-io/node-usb was forked, and I am able to reproduce the same issue.

I’m pretty unfamiliar with node-gyp and node-pre-gyp, but there are a couple of other forum threads and github issues I’ve stumbled upon that suggest my environment might not be properly configured for node-gyp. If this is the case, @mjjames or @jviotti Are either of you familiar with node-gyp and what we might have to do to configure my environment properly or debug our node-gyp environment further?

Thanks in advance for your help!

Hi Everyone,

So it looks like I spoke too soon about my local node-usb installation tests. I forgot to use the --recursive flag with the git clone command, which caused the libusb submodule to not be cloned. I ran git submodule init && git submodule update to clone the libusb submodule, and npm install now runs successfully.

This solves my issue with installing the node-usb module locally but does not fully address the issue with installing balena-cli when running npm install balena-cli -g --production. This could be a good hint at the final solution though. My next steps are to figure out if the libusb submodule is cloned when npm fetches the node-usb dependency while installing balena-cli (or node-raspberrypi-usbboot, which seems to be the balena-cli dependency that has node-usb as a dependency).

Hi @mjjames,

I found a bit of time to revisit this issue and I think I’ve found a path forward for me. I am only able to build and install balena-cli on my Ubuntu 18.04 system using node and npm when it is installed through nvm, as opposed to a system installation through apt. My only hypothesis as to why this works would be the fact that I’m installing nvm as a non-root user. So when I install node through nvm, it is also installed as a non-root user with non-root permissions.

The README of nvm seems to indicate that it works on certain versions of WSL, so I wonder if using nvm will help resolve your issue? Best of luck! Let me know how it goes :slight_smile:

Cheers,
Rob Weber

Installing on ubuntu 18.04 with npm works but:

  • you need a newer npm than the one installed by apt
  • you need to pass --unsafe-perm to install globally

Here’s a working Dockerfile:

FROM ubuntu:18.04
RUN apt-get update && apt-get install -y npm git
RUN npm i -g npm@6
RUN npm i -g --unsafe-perm balena-cli
RUN balena --version

I’m not sure it will work in WSL.

Hello @robbawebba,

Just installed the balena-cli on windows 10 wsl, everything freshly installed.

These are the steps to replicate:

Steps to install balena-cli on windows 10 wsl.

  • Install WSL (https://linoxide.com/distros/how-install-ubuntu-windows-10/)

  • Install Ubuntu :arrow_heading_up:

  • Update software:

    • sudo apt-get update
    • sudo apt-get upgrade
    • sudo apt-get install build-essential
    • sudo apt install python install python
  • Install Node:

    • curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash and reload terminal
    • nvm install stable
    • nvm use stable
  • Install balena-cli

    • Install balena-cli: npm install balena-cli -g --production --unsafe-perm

Link to the steps on gist: https://gist.github.com/dansku/645a4fef2501a7167c98bc01c94ec20c

Please let me know if it helps,
Cheers