fossas / spectrometer

Flexible, robust, and performant dependency analysis.
Mozilla Public License 2.0
21 stars 7 forks source link

Install script can show misleading `cp` error message when copying executable #390

Closed rolodato closed 2 years ago

rolodato commented 2 years ago

Running install.sh can show a misleading error message if the user has recently authenticated with sudo or does not have a password set.

Under normal use, the install script prints cp: cannot create regular file '/usr/local/bin/fossa': Permission denied and then prompts the user for their sudo password as expected:

rolodato@FOSSPAD:~$ curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/spectrometer/master/install.sh | bash
[...]

cp: cannot create regular file '/usr/local/bin/fossa': Permission denied
[sudo] password for rolodato:
fossas/spectrometer info installed /usr/local/bin/fossa

However, if the user doesn't need to be prompted for their sudo password, this error message is still shown and it's not immediately clear if the installation succeeded (it did):

rolodato@FOSSPAD:~$ curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/spectrometer/master/install.sh | bash
[...]

cp: cannot create regular file '/usr/local/bin/fossa': Permission denied
fossas/spectrometer info installed /usr/local/bin/fossa

fossa-cli's installer does not have this problem, as it silences the stderr output of non-sudo commands if they are immediately retried with sudo on failure. It also uses install instead of cp to copy the executable into the target directory which is a better tool for this job, but is not a POSIX program so we can't ensure it will be present.

meghfossa commented 2 years ago

I believe this is addressed with your recent merge @rolodato. If not, can you add it to internal team-analysis milestone: https://github.com/fossas/team-analysis/milestone/41