balena-io / balena-cli

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

Simplify CLI installation and first usage #1711

Open pdcastro opened 4 years ago

pdcastro commented 4 years ago

User experience / product feedback (gsheet, flowdock) is that the CLI installation (and first usage) is "pretty complicated". Some specific action points have been identified:

All subtasks identified in this issue have also been added to a GitHub project: https://github.com/balena-io/balena-cli/projects/3

frederikheld commented 3 years ago

I just found some more issues with balena-cli. Might be related to the installation process (and could be fixed with a proper installer).

a) if I do $ balena login but then $ sudo balena preload, balena-cli tells me that I'm not logged in. So I have to do $ sudo balena login separately. But this does not open the website automatically, I have to click on the link manually.

I don't remember having this issue on my old computer. So it might be related to the fact that I installed balena-cli first and then docker, which brings me to the next issue:

b) balena-cli does not tell me that I need to install docker first. Of course, there's no installer. But the installation instructions don't tell me either and balena doesn't mention missing docker engine until it fails because of the missing docker engine.

Should I submit separate issues for that?

pdcastro commented 3 years ago

Thank you for the feedback @frederikheld 👍

if I do $ balena login but then $ sudo balena preload, balena-cli tells me that I'm not logged in.

As far as I am aware, the balena preload command does not require sudo if Docker is configured to run without sudo. In PR #2208, which was inspired by your contributions in #2149 and #2206 🙏, I am adding a note on how to configure Docker to run without sudo.

If there is a CLI command that requires login and also requires sudo, we will need to amend documentation further. A workaround is to the use the sudo -E flag. For example, I believe that sudo -E balena preload would not require you to log in again if you are already logged as a regular user.

The explanation is that the CLI creates a ~/.balena/token file in the homedir, e.g. /home/paulo/.balena/token. But when we use sudo, in some Linux distros, sudo switches the homedir to /root and the CLI will then look at /root/.balena/token. The sudo -E flag causes sudo not to switch the homedir by preserving the environment variables, including $HOME.

For the record, :-) we are amending documentation as an easy, short-term workaround to what are really design / implementation issues. Code changes to implement dynamic privilege escalation, dynamic environment detection, and improved CLI installers would avoid the need of a number of manual installation steps and respective documentation.

But the installation instructions don't tell me either and balena doesn't mention missing docker engine until it fails because of the missing docker engine.

The Linux installation instructions, Additional Dependencies section, mention that Docker is required for the balena build, deploy and preload commands. Other than that, I think that issue 1719 Detect and facilitate Docker installation would be best -- the CLI could install Docker for the user, or at least dynamically ask the user to install Docker, including validating the installation if something is missing, for example if Docker is configured to require the use of sudo.

Should I submit separate issues for that?

With regard to sudo and installers, the problem is not lack of issues, it's lack of developer hours to solve the known issues. :-) In addition to the issues already linked from this issue, other sudo-related issues include:

477, #385, #542, #550, #572, #940, #1444, #1714, #2062, #2101, #2149

They compete with ~300 other issues just in the balena-cli repo, plus lots of other issues in tens of other git repositories used by the balena-cli repo. The platform codebase is massive, but also almost completely open source, and community contribution is welcome. ;-)

frederikheld commented 3 years ago

Thanks for the clarification :-)

I would actually like to contribute more, but it's difficult to find time between my day job and side projects. And installers aren't my turf yet :-P But I just started to use balena, I might contribute more as soon as I understand it better :-)