Improvement: Add deduplication check in bashrc/zshrc 00-init to prevent unbounded PATH growth

Abierto
#1,824 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@mylinuxforwork ya está trabajando en esto.

Desde el 5/9/2026.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug
Describe the bug

In ~/.config/bashrc/00-init and ~/.config/zshrc/00-init, the cargo and local bin directories are appended directly to $PATH without checking if they are already present:

export PATH=$PATH:~/.cargo/bin/
export PATH=$PATH:~/.local/bin/

In standard daily terminal usage, this goes unnoticed because a fresh terminal only sources .bashrc once.
However, in more advanced setups (e.g. running background widgets like Quickshell, custom toolchains, nested subshells invoking bash -c, or scripts that re-source the shell environment), 00-init can be executed multiple times within the same session hierarchy.
Because there is no duplicate check, the exact same paths are appended over and over again. Eventually, $PATH can grow to hundreds of kilobytes and hit the Linux kernel limit (ARG_MAX), resulting in:

  • E2BIG: Argument list too long on new process executions.
  • Compositor shortcuts failing to spawn programs.
    Adding a simple check before appending makes 00-init idempotent and bulletproof against repeated sourcing.
Steps to reproduce
1. Open a terminal and check the length of `$PATH`:
   `echo $PATH | wc -c`
2. Simulate repeated subshell invocations or run the desktop session across multiple sleep/wake cycles:
   `for i in {1..50}; do bash -c 'true'; done`
3. Inspect `$PATH`:
   `echo $PATH`
4. Notice dozens of duplicated `~/.cargo/bin` and `~/.local/bin` entries inflating the environment size.

### Expected behavior

Pads should only be added to `$PATH` if they are not already present, preventing duplicate entries and buffer overflows regardless of how often subshells are spawned.
**Proposed fix for `00-init`:**
```bash
# Add ~/.cargo/bin if not already in PATH
case ":$PATH:" in
    *":$HOME/.cargo/bin:"*) ;;
    *) export PATH="$PATH:$HOME/.cargo/bin" ;;
esac
# Add ~/.local/bin if not already in PATH
case ":$PATH:" in
    *":$HOME/.local/bin:"*) ;;
    *) export PATH="$PATH:$HOME/.local/bin" ;;
esac

### Screenshots

_No response_

### Distribution

Other (please specify below)

### If Other, specify

CachyOS

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct
Lenguaje dominante
QML
Estrellas
5.1k
Forks
386
Merge medio
16 h 45 min
PR fusionados (30 d)
14

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de mylinuxforwork/dotfiles

Todos los issues de mylinuxforwork/dotfiles

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.