Closed jimmyw closed 3 years ago
Starting with a disclaimer: Neither Homebrew nor Node v14 are "officially" supported by the balena CLI, in fact I am aware that some CLI commands don't work with Node v14. (The balena-cli distribution over Homebrew has been independently setup and maintained by a balena user.) The officially supported installation options are documented at: https://github.com/balena-io/balena-cli/blob/master/INSTALL.md
Having said that, the balena device
command "works for me" with macOS Mojave (10.14.6) and Node v14.3.0 (same as yours), even when using Homebrew:
$ brew install balena-cli
$ ls -l /usr/local/bin/balena
lrwxr-xr-x 1 paulo admin 39 31 Jul 17:24 /usr/local/bin/balena -> ../Cellar/balena-cli/12.10.0/bin/balena
$ $ /usr/local/bin/balena version -a
balena-cli version "12.10.0"
Node.js version "14.3.0"
$ /usr/local/bin/balena device dcbff32a --debug
[debug] new argv=[/Users/paulo/.nvm/versions/node/v14.3.0/bin/node,/usr/local/bin/balena,device,dcbff32a] length=4
== FROSTY SNOW
ID: 1958859
DEVICE TYPE: raspberrypi4-64
STATUS: offline
...
Also, not using Homebrew, and using instead nvm:
$ nvm use 14.3.0
Now using node v14.3.0 (npm v6.14.5)
$ node --version
v14.3.0
$ npm install -g --production --unsafe-perm balena-cli
$ which balena
/Users/paulo/.nvm/versions/node/v14.3.0/bin/balena
$ balena device b1878c6
== 94:C6:91:A1:68:22 PDCASTRO
ID: 1616110
DEVICE TYPE: intel-nuc
STATUS: idle
IS ONLINE: true
...
I suggest you try using the graphical installer for macOS, which I've just successfully tested here as well. It bundles its own Node.js (currently Node.js v10.21.0), and avoids most installation issues.
Also, the error you were getting was BalenaRequestError: Request error: Internal Server Error
. Could it have been a temporary balenaCloud backend glitch that got sorted by now?
@jimmyw, those API logs are from openBalena, right? Now it rings a bell. I think the issue may be an incompatibility with the balena SDK version used by recent versions of balena CLI. Could you try downgrading balena CLI to version 12.3.3? - https://github.com/balena-io/balena-cli/releases?after=v12.3.4
I confirm it's working with CLI v12.3.3
@pdcastro Sorry, I forgot to mention its open balena.
Yes, it's stopped working after an upgrade, I can absolutely give the old version a try.
@pdcastro
Maybe you can help, if i check out v12.3.3 and run
$ npm install balena-cli -g
I will still end up with balena-cli 12.10.1, tried to flush the full npm folder, but same result.
I will still end up with balena-cli 12.10.1
It's probably a case of multiple installations. A command that may help identify what is installed is which balena
:
$ which balena
/Users/paulo/.nvm/versions/node/v14.3.0/bin/balena
vs.
$ which balena
/usr/local/bin/balena
The latter would be the Homebrew installation:
$ ls -l /usr/local/bin/balena
lrwxr-xr-x 1 paulo admin 39 31 Jul 17:24 /usr/local/bin/balena -> ../Cellar/balena-cli/12.10.0/bin/balena
(The Cellar
folder in the path indicates Homebrew.)
Perhaps uninstall the brew installation:
$ brew uninstall balena-cli
Uninstalling /usr/local/Cellar/balena-cli/12.10.0... (42,548 files, 345.9MB)
In some rare cases, which balena
indicates one path but running balena
actually runs something else. I am not sure why, but from experience it gets resolved by closing the command terminal window and opening a new fresh one. Also, to be completely sure of what balena
is being executed, use the full path:
# the output below was actually captured for the macOS graphical installer
$ /usr/local/bin/balena version -a
balena-cli version "12.10.1"
Node.js version "10.21.0"
$ /Users/paulo/.nvm/versions/node/v14.3.0/bin/balena version -a
balena-cli version "12.10.1"
Node.js version "14.3.0"
By the way, if using the npm installation method, I suggest using Node.js v10 or Node.js v12, which are better tested and supported by the balena CLI. And to install Node.js, I suggest using nvm (not to be confused with npm
, note the middle character!).
$ nvm install 12
Downloading and installing node v12.18.3...
...
$ nvm use 12
Now using node v12.18.3 (npm v6.14.6)
$ node --version
v12.18.3
$ npm i -g --production --unsafe-perm balena-cli@12.3.3
+ balena-cli@12.3.3
added 2345 packages from 1949 contributors in 49.774s
$ which balena
/Users/paulo/.nvm/versions/node/v12.18.3/bin/balena
21:14 $ balena version -a
balena-cli version "12.3.3"
Node.js version "12.18.3"
Also I should add: It sounds like you prefer the brew
or npm
installation methods, which is fine, but the least troublesome installation options are either the standalone zip file for macOS or the native/graphical macOS installer, as documented, mainly because they bundle their own copy of Node.js with the installer (and that copy of Node.js will not interfere with the system installation or with nvm
). (And the installers are available in the releases page for any CLI version, including v12.3.3.)
I switched to my ubuntu machine, but have the same issue here
$ balena --version -a
balena-cli version "12.10.1"
Node.js version "10.22.0"
$ cat ~/.npmrc
prefix = /home/jimmy/.npm-packages
$ which balena
/home/jimmy/.npm-packages/bin/balena
$ rm -rf ~/.npm-packages
$ balena --version
bash: /home/jimmy/.npm-packages/bin/balena: No such file or directory
$ git co v12.3.3
HEAD is now at 21c8a38c v12.3.3
$ git branch
* (HEAD detached at v12.3.3)
$ git clean -xfd
$ npm install -g balena-cli
<lots of output ...>
$ balena --version -a
balena-cli version "12.10.1"
Node.js version "10.22.0"
This is really strange to me, are there any caches I missed?
$ git co v12.3.3
$ npm install -g balena-cli
Those two commands don't usually go together: It is not necessary to git clone
the balena-cli repo in order to install the balena CLI "globally" with the npm install -g
command (the -g
flag), even if installing older versions of the CLI.
The following command specifically will install the latest version of the CLI (12.10.1), regardless of git co v12.3.3
:
$ npm install -g balena-cli
To install the v12.3.3 of the balena CLI globally, append @12.3.3
to the package name:
$ npm install -g --production balena-cli@12.3.3
--production
will save some 200MB (?) disk space, and --unsafe-perm
is useful if running as the root
user.
There is no need to git clone
/ git checkout
unless you are planning to modify the CLI source code (btw, contributions are welcome!). :-)
@pdcastro
Ok, thanks for the clarification.
I did actually want to modify the code, I tried to add additional logging but failed to test it, how do you build from the current git sources?
12.3.3 failed :(
$ npm install -g --production balena-cli@12.3.3
/home/jimmy/.npm-packages/bin/balena -> /home/jimmy/.npm-packages/lib/node_modules/balena-cli/bin/balena
> balena-cli@12.3.3 postinstall /home/jimmy/.npm-packages/lib/node_modules/balena-cli
> patch-package --patch-dir patches0 && patch-package
patch-package 6.2.2
Applying patches...
patch-package@6.2.2 ā
patch-package 6.2.2
Applying patches...
**ERROR** Failed to apply patch for package @oclif/dev-cli at path
node_modules/@oclif/dev-cli
This error was caused because patch-package cannot apply the following patch file:
patches/@oclif+dev-cli+1.22.0.dev.patch
Try removing node_modules and trying again. If that doesn't work, maybe there was
an accidental change made to the patch file? Try recreating it by manually
editing the appropriate files and running:
patch-package @oclif/dev-cli
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
https://github.com/ds300/patch-package/issues
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/balena-cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/balena-cli/node_modules/livepush/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: winusb-driver-generator@1.2.4 (node_modules/balena-cli/node_modules/winusb-driver-generator):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for winusb-driver-generator@1.2.4: wanted {"os":"win32","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: macmount@1.0.0 (node_modules/balena-cli/node_modules/macmount):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for macmount@1.0.0: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
+ balena-cli@12.3.3
added 8 packages from 6 contributors and updated 1 package in 3.969s
I did actually want to modify the code
Oh, that's cool! Start by having a look at the Contributing document. In this case, don't use the -g
flag to the npm install
command, or any other arguments really:
$ git co v12.3.3
$ npm install
Then follow it with npm run build
, and run the CLI with ./bin/balena
:
$ git co v12.3.3
$ npm install
$ npm run build
$ ./bin/balena version -a
balena-cli version "12.10.0"
Node.js version "10.22.0"
ERROR Failed to apply patch for package @oclif/dev-cli at path
See this issue: https://github.com/balena-io/balena-cli/issues/1751
Basically, when changing between CLI versions (whether downgrading or upgrading) and installing via npm, it may be necessary to the delete the relevant node_modules
folder.
Thanks for your patience with me :)
Okay, i can confirm that $ balena device
works with version 12.3.3.
I hope this is helpful!
I hope this is helpful!
Yes, thank you for creating this issue! I am labelling it as a bug in the balena CLI, although the underlying issue seems to be that openBalena releases have not kept up with recent changes to the balena SDK. There is an ongoing internal discussion on how to address this.
cc: @thgreasi, @Page-, @srlowe : The workaround for this issue (SDK / openBalena compatibility) was to downgrade the CLI to v12.3.3.
I see @pdcastro . It looks like it's the overall_status
that's breaking the requests.
Here is the respective open-balena issue
See: https://github.com/balena-io/open-balena-api/issues/338
@thgreasi, @Page-, @srlowe, FYI, a complication with the current advice to openBalena users to downgrade to v12.3.3 is that that version is affected by the PinejsClientCore
bug in commands like balena scan
and balena config inject
. See issue #1971. Also: internal flowdock thread.
@pdcastro based on the changelog, maybe they can try using v12.2.2. Looks promising to me wrt the the balena-pine <-> pine-client-core issue.
openBalena version 3 has been released, š
https://github.com/balena-io/open-balena/blob/master/CHANGELOG.md
It includes support for the new API endpoints and newer versions of the balena SDK, and therefore the latest CLI releases. I have tested openBalena v3 with CLI v12.25.6 (currently the latest version), and the balena device
command in particular was successful:
$ balena device 7d0cb2c
== BOLD PAPER
ID: 2
DEVICE TYPE: raspberrypi3
STATUS: idle
IS ONLINE: true
IP ADDRESS: 192.168.1.36
MAC ADDRESS: B8:27:EB:94:74:69 B8:27:EB:C1:21:3C
APPLICATION NAME: myApp
LAST SEEN: 2020-10-29T02:17:13.200Z
UUID: 7d0cb2cb6e2e84ca7e75e554a9a8069b
COMMIT: N/a
SUPERVISOR VERSION: 11.14.0
IS WEB ACCESSIBLE: false
OS VERSION: balenaOS 2.58.3+rev1
DASHBOARD URL: https://dashboard.vestamon.co.uk/devices/7d0cb2cb6e2e84ca7e75e554a9a8069b/summary
CPU USAGE PERCENT: 6
CPU TEMP C: 45
CPU ID: 000000000894746
MEMORY USAGE MB: 278
MEMORY TOTAL MB: 745
MEMORY USAGE PERCENT: 37
STORAGE BLOCK DEVICE: /dev/mmcblk0
STORAGE USAGE MB: 74
STORAGE TOTAL MB: 13929
STORAGE USAGE PERCENT: 1
For older versions of openBalena (older than v3.0.0), the recommendation remains to downgrade the CLI to v12.2.2.
Expected Behavior
Expecting to get device data
Actual Behavior
Server side:
Specifications
Additional References