aws / aws/amazon-q-developer-cli

bug: (short issue descriptionDuplicate ~/.local/bin in PATH due to incorrect path existence check in Amazon Q shell scripts)

Aperta
#2,013 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
2k
Fork
439
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue

### Operating system

Linux (Ubuntu/Debian-based distribution)

### Expected behaviour

Describe the bug
Amazon Q shell scripts (profile.pre.bash and profile.post.bash) incorrectly check for the existence of ~/.local/bin in the PATH
variable, which leads to this path being added twice to the PATH. The current check [[ ":$PATH:" != ":$_Q_LOCAL_BIN:" ]] doesn't
properly detect if the path is already present.

Regression Issue

Select this option if this issue appears to be a regression.
Expected Behavior
The PATH variable should contain ~/.local/bin only once. The check in Amazon Q shell scripts should correctly detect if the path is
already present in PATH and not add it again.

### Actual behaviour

Current Behavior
The PATH variable contains ~/.local/bin twice:
/home/user/.local/bin:/other/paths:/home/user/.local/bin

This happens because:

~/.profile adds ~/.local/bin to PATH
Amazon Q shell scripts (profile.pre.bash and profile.post.bash) add it again due to incorrect path existence check

### Steps to reproduce

Reproduction Steps
Have ~/.local/bin added to PATH in ~/.profile (standard in many Linux distributions)
Install Amazon Q CLI
Check PATH variable with echo $PATH
Observe that ~/.local/bin appears twice in the PATH
Possible Solution
Replace the current check in both profile.pre.bash and profile.post.bash:

From:
bash
[[ ":$PATH:" != ":$_Q_LOCAL_BIN:" ]] && PATH="${PATH:+"$PATH:"}$_Q_LOCAL_BIN"

To a more accurate check using regex:
bash
if [[ ! "$PATH" =~ (^|:)"$_Q_LOCAL_BIN"(:|$) ]]; then
PATH="${PATH:+"$PATH:"}$_Q_LOCAL_BIN"
fi

This regex properly checks if the path exists as a complete segment in the PATH variable.

Additional Information/Context
This issue doesn't cause functional problems but is a minor inefficiency as the shell has to search the same directory twice when
looking for executables.

CLI version used
Amazon Q CLI (latest version)

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia leggendo profile.pre.bash e profile.post.bash, quindi riproduci il problema con ~/.local/bin già presente in PATH e analizza i controlli di esistenza esistenti. Il lavoro è completato quando ogni script lascia ~/.local/bin come un unico segmento completo di PATH, inclusa la configurazione Ubuntu/Debian indicata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
shell
Ambito
cli
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.