balena-io / balena-cli

The official balena CLI tool.
Apache License 2.0
452 stars 138 forks source link

Improve `balena scan` sudo situation #1714

Open pdcastro opened 4 years ago

pdcastro commented 4 years ago

As per product feedback (gsheet), "balena scan requires admin privileges but the message is messy and hard to understand".

Instead of the current message:

PS C:\Users\paulo> balena scan
You don't have sufficient privileges to run this operation.
Run a new Command Prompt as administrator and try running this command again.

If this is not the case, and you're trying to burn an SDCard, check that the write lock is not set.
PS C:\Users\paulo> balena scan
This command needs to be run as an administrator. Open a new command prompt
using the start menu "Run As Administrator" option. For additional guidance, see:
https://www.howtogeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/

Perhaps avoid the howtogeek link by choosing a widely available method and explaining how to do it in very few sentences (1-2-3 steps?) on the CLI output itself. Be sure that this explanation is not printed in red-on-bue! See #1712

pdcastro commented 4 years ago

Connects-to: #542

Sukhoimaster commented 3 years ago

I fix this by adding balena /bin directory in the secure_path option in /etc/sudoers

Using : Linux 16.04.1-Ubuntu x86_64 x86_64 x86_64 GNU/Linux Kernel : 4.15.0-106-generic NPM : 6.14.4 Nodes : v10.20.0

After complete via NPM installation as per https://github.com/balena-io/balena-cli/blob/master/INSTALL.md#npm-installation

the path output will be added to the secure_path option in /etc/sudoers

As in my case /home/sonix/.nvm/versions/node/v10.20.0/bin/

Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/sonix/.nvm/versions/node/v10.20.0/bin/"

CTRL + X to save then Yes . In return resulting visudo: /etc/sudoers.tmp saved

After this fix , resolve all the privileges and sudo:balena: Command not found issue

Able to run balena without sudo

srlowe commented 3 years ago

@pdcastro I think we should close either this or #542 as duplicate, since they are the same issue.