install: guard against duplicate PATH entries on reinstall#2565
install: guard against duplicate PATH entries on reinstall#2565marcelsafin wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the installer’s PATH configuration step idempotent by checking whether the intended PATH export line is already present in the selected shell profile before appending it, preventing duplicate entries when re-running the installer in the same shell session.
Changes:
- Add a
grep -qFpresence check forPATH_LINEinRC_FILEbefore appending. - Print a distinct message when PATH configuration is already present instead of writing again.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3e92702 to
cdbdbb0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Running the installer twice without restarting the shell causes the PATH configuration line to be appended to the shell profile a second time, since the script only checks whether copilot is in PATH (which requires a shell restart to take effect) before prompting. Check whether the exact PATH_LINE already exists in RC_FILE before appending. This makes the write idempotent—reinstalls and upgrades skip the duplicate and report that the configuration is already present.
cdbdbb0 to
c775cd5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot review (Previous review comments were against earlier revisions — current diff incorporates all the requested changes.) |
|
@copilot review |
|
This remains mergeable and Copilot found no outstanding issues. Could a maintainer take another look? |
Running the installer twice without restarting the shell causes the PATH configuration line to be appended to the shell profile a second time. This happens because the script checks
command -v copilotto decide whether to prompt for PATH setup, but that check requires a shell restart to reflect the previous install's RC_FILE changes.Repro:
Result:
~/.bash_profile(or equivalent) contains the sameexport PATH=...line twice.This adds a
grep -qFcheck for the exactPATH_LINEinRC_FILEbefore appending, making the write idempotent. On reinstall, the script reports that the configuration is already present instead of duplicating it.Before (reinstall):
After (reinstall):
Works for all shells (bash, zsh, fish, POSIX fallback) since it matches the exact
PATH_LINEstring.