Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Shell installer: updating PATH replaces symlinked profiles and changes existing file permissions

Aperta Adatta ai principianti
#51,544 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Il bug si trova nella logica di riscrittura del blocco PATH dell'installer, specificamente nella funzione rewrite_path_block che scrive su un file temporaneo e lo sposta sul pathname del profilo. Parti dallo script dell'installer (probabilmente sotto scripts/install.sh) e dal fixture di test in scripts/install/test_install_sh.py. Usa lo script di riproduzione fornito per confermare il problema, poi modifica la riscrittura in modo da risolvere i symlink, conservare la modalità del file originale e aggiornare il file di destinazione invece di sostituire il symlink. Esegui la suite di test dell'installer per verificare la correzione.

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

Descrizione

bug CLI
What issue are you seeing?

When a shell profile already contains a Codex PATH block and is a symlink into a dotfiles directory, rerunning the shell installer replaces that symlink with a regular file. Its original dotfiles target is not updated. The same rewrite also changes an existing regular profile's mode to the temporary file's mode.

Confirmed on main ac9b5b8380517ded445b09dd3196d8d9e2ba3c59 with the existing local installer fixture on Linux, using its macOS mock. This does not establish behavior on an actual macOS host.

What steps can reproduce the bug?

Save and run python installer-profile-symlink-repro.py /path/to/codex-checkout. All package downloads are mocked by the existing local fixture; all profile writes remain in a temporary directory.

#!/usr/bin/env python3
"""Local installer fixture on Linux with mocked macOS; no network or user profile writes.

Usage: python installer-profile-symlink-repro.py /path/to/codex-checkout
"""

import importlib.util
from pathlib import Path
import stat
import sys
import tempfile


checkout = Path(sys.argv[1]).resolve()
spec = importlib.util.spec_from_file_location(
    "installer_fixture", checkout / "scripts/install/test_install_sh.py"
)
fixture = importlib.util.module_from_spec(spec)
spec.loader.exec_module(fixture)

with tempfile.TemporaryDirectory(prefix="codex profile repro ") as temporary:
    root = Path(temporary).resolve()
    archive, checksum, metadata = fixture.create_package_release(root)
    (root / "home").mkdir()
    (root / "dotfiles").mkdir()
    target = root / "dotfiles/profile"
    profile = root / "home/.profile"
    profile.symlink_to("../dotfiles/profile")
    target.write_text(
        'export EXISTING_SETTING="keep this"\n'
        '# >>> Codex installer >>>\nexport PATH="/old/bin:$PATH"\n'
        "# <<< Codex installer <<<\n"
    )
    target.chmod(0o640)

    result, _ = fixture.run_installer_in(
        root,
        fixture.VERSION,
        metadata_json=metadata,
        archive_path=archive,
        checksum_path=checksum,
        force_macos=True,
    )

    print(f"installer_exit={result.returncode}")
    print(f"profile_is_symlink={profile.is_symlink()}")
    print(f"dotfiles_target_updated={str(root / 'install-bin') in target.read_text()}")
    print(f"profile_mode={oct(stat.S_IMODE(profile.stat().st_mode))}")
    print(f"dotfiles_target_mode={oct(stat.S_IMODE(target.stat().st_mode))}")
    print(f"existing_setting_preserved={'keep this' in profile.read_text()}")
    if result.stderr:
        print(f"stderr={result.stderr.strip()}")

With the original installer:

installer_exit=0
profile_is_symlink=False
dotfiles_target_updated=False
profile_mode=0o600
dotfiles_target_mode=0o640
existing_setting_preserved=True

The resulting mode depends on the ambient umask; 0600 is the observed value here, not a universal value.

What is the expected behavior?

Updating the installer-managed PATH block should preserve the user's profile symlink, update its target, retain unrelated content, and preserve the existing profile permissions.

Additional information

rewrite_path_block() writes a temporary file and moves it over the profile pathname. The move replaces the symlink instead of following it, and the temporary file does not retain the original file's mode.

I tested a candidate that resolves the final profile target, stages the update beside that target while retaining its file metadata, and replaces the target instead of the profile symlink. The reproduction then preserves the symlink, updates the dotfiles target, and retains mode 0640. The complete installer suite passes 23 tests and 11 subtests; coverage includes linked profile chains, a regular profile's mode, first-time appends, first-time writes through a broken link whose target directory exists, and failure cleanup that leaves original content intact. Shell syntax and diff checks pass.

Searched installer/profile/symlink and dotfiles reports and found no equivalent issue. No external PR is requested, consistent with the contribution policy.

Lingua principale
Rust
Stelle
130k
Fork
20.5k
Merge medio
1m
PR unite (30g)
996

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di openai/codex

Tutte le issue di openai/codex

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.