Unverified Commit e41e22d7 authored by per1234's avatar per1234 Committed by GitHub

[skip changelog] Improve install script's check for conflicting installation in $PATH (#822)

* Make install script's check for conflicting $PATH installation more reliable

Previously, the comparison between the install script's target path and the path of an existing installation in $PATH could easily give a false positive, producing a spurious "An existing arduino-cli was found at..." error. The solution is to fully resolve the paths before comparing them.

* Don't fail installation script when other installation in $PATH is detected

Previously, when a different installation of Arduino CLI was detected in $PATH by the installation script, the error message "Failed to install arduino-cli" would be printed and the script would have exit status 1.

It is wise that the script warns of this situation ("An existing arduino-cli was found at..."), but the "Failed to install arduino-cli" error message was misleading, since Arduino CLI was indeed installed. It is also incorrect to have an error exit status in this situation, since the user may intend to have multiple installations and provide the full path when using the new installation.
parent a2f63fbc
......@@ -191,8 +191,13 @@ testVersion() {
CLI="$(which $PROJECT_NAME)"
if [ "$?" = "1" ]; then
echo "$PROJECT_NAME not found. You might want to add "$LBINDIR" to your "'$PATH'
elif [ $CLI != "$LBINDIR/$PROJECT_NAME" ]; then
fail "An existing $PROJECT_NAME was found at $CLI. Please prepend "$LBINDIR" to your "'$PATH'" or remove the existing one."
else
# Convert to resolved, absolute paths before comparison
CLI_REALPATH="$(cd -- "$(dirname -- "$CLI")" && pwd -P)"
LBINDIR_REALPATH="$(cd -- "$LBINDIR" && pwd -P)"
if [ "$CLI_REALPATH" != "$LBINDIR_REALPATH" ]; then
echo "An existing $PROJECT_NAME was found at $CLI. Please prepend "$LBINDIR" to your "'$PATH'" or remove the existing one."
fi
fi
set -e
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment