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)
- Lenguaje dominante
- Rust
- Estrellas
- 2k
- Forks
- 439
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### 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)
Guía de contribución
Línea de trabajo
Empieza leyendo profile.pre.bash y profile.post.bash; después reproduce el problema con ~/.local/bin ya presente en PATH e inspecciona las comprobaciones de existencia existentes. El trabajo estará terminado cuando cada script deje ~/.local/bin como un único segmento completo de PATH, incluido el setup de Ubuntu/Debian indicado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- shell
- Área
- cli
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 55/100