Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix install script's check for previous installation #1603

Merged
merged 1 commit into from
Dec 20, 2021
Merged

Fix install script's check for previous installation #1603

merged 1 commit into from
Dec 20, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Dec 20, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

Infrastructure fix.

  • What is the current behavior?

The installation script checks for an existing installation in the PATH in order to provide appropriate advice to the
user about adding the installation to their their PATH environment variable.

This check is done using command -v. It turns out that the exit status is shell dependent in the event the command is
not found, so that it might be either 1 or 127 depending on the user's system. The script previously assumed that the
exit status would be 1 when the command was not found in PATH, which resulted in spurious advice under these conditions:

An existing arduino-cli was found at . Please prepend "/home/foo/arduino-cli/bin" to your $PATH or remove the existing one.

example

  • What is the new behavior?

Previous installation check's logic is inverted so that the advice about an existing installation in PATH is only printed when one was found, making it only dependent on exit status 0.

No breaking change.

  • Other information:

See upstream commits for more atomic breakdown of changes: arduino/tooling-project-assets#189

Checks for proper behavior of this aspect have been added for the parent: https://github.com/arduino/tooling-project-assets/actions/runs/1601562939


Originally reported at https://forum.arduino.cc/t/failing-to-instlal-arduino-cli-on-raspberry/936871

The installation script checks for an existing installation in the PATH in order to provide appropriate advice to the
user about adding the installation to their their PATH environment variable.

This check is done using `command -v`. It turns out that the exit status is shell dependent in the event the command is
not found, so that it might be either 1 or 127 depending on the user's system. The script previously assumed that the
exit status would be 1 when the command was not found in PATH, which resulted in spurious advice under these conditions:

```
An existing arduino-cli was found at . Please prepend "/home/foo/arduino-cli/bin" to your $PATH or remove the existing one.
```

It seems safest to fix this by inverting the logic so that the advice about an existing installation in PATH is only
printed when one was found.
@per1234 per1234 added topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project labels Dec 20, 2021
@per1234 per1234 self-assigned this Dec 20, 2021
@per1234 per1234 merged commit 8638657 into arduino:master Dec 20, 2021
@per1234 per1234 deleted the fix-install-script branch December 20, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: infrastructure Related to project infrastructure type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants