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

Shell installer: relative CODEX_HOME breaks package links and relative CODEX_INSTALL_DIR writes a cwd-dependent PATH

Aperta Adatta ai principianti
#51,538 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
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
bash
Ambito
cli

Direzione di ricerca

L'installatore shell scrive percorsi relativi come destinazioni di symlink e voci di profilo quando CODEX_HOME o CODEX_INSTALL_DIR sono relativi. Parti dallo script di installazione esercitato da scripts/install/test_install_sh.py, individua dove CODEX_HOME_DIR e BIN_DIR vengono usati per costruire il symlink corrente e la voce PATH, e convertili in percorsi assoluti. Esegui la suite di test dell'installatore per confermare la correzione.

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

Descrizione

bug CLI
What issue are you seeing?

The shell installer generates a broken current symlink when CODEX_HOME is relative. The package is unpacked successfully, but a normal install exits 127 when it verifies the visible command. In daemon-only mode installation can exit 0 while current/bin/codex remains unusable.

A related path problem occurs when CODEX_INSTALL_DIR is relative: the visible link works from the installation directory, but the generated profile PATH entry is relative, so codex stops resolving after the working directory changes.

Checked main at ac9b5b8380517ded445b09dd3196d8d9e2ba3c59. Evidence below uses the existing local installer fixture on Linux, with its macOS mock; this is not a test on a real macOS host.

What steps can reproduce the bug?

Save the following script and run python installer-relative-home-repro.py /path/to/codex-checkout. It uses the checkout's existing package/download fixture, requires no network, and confines profile writes to a temporary directory.

#!/usr/bin/env python3
"""Local installer reproduction; uses Linux with the fixture's macOS mock.

Usage: python installer-relative-home-repro.py /path/to/codex-checkout
All downloads and profile writes are confined to the existing local fixture.
"""

import importlib.util
from pathlib import Path
import subprocess
import sys
import tempfile
from unittest.mock import patch


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

with tempfile.TemporaryDirectory(prefix="codex installer repro ") as temporary:
    root = Path(temporary).resolve()
    archive, checksum, metadata = fixture.create_package_release(root)

    def run_with_relative_home(args, **kwargs):
        if len(args) > 1 and Path(args[1]) == fixture.INSTALL_SCRIPT:
            kwargs["env"] = {**kwargs["env"], "CODEX_HOME": "codex-home"}
            kwargs["cwd"] = root
        return original_run(args, **kwargs)

    with patch.object(fixture.subprocess, "run", side_effect=run_with_relative_home):
        result, _ = fixture.run_installer_in(
            root,
            fixture.VERSION,
            metadata_json=metadata,
            archive_path=archive,
            checksum_path=checksum,
            force_macos=True,
        )

    current = root / "codex-home/packages/standalone/current"
    package = current.parent / "releases" / f"{fixture.VERSION}-aarch64-apple-darwin"
    visible = root / "install-bin/codex"
    print(f"installer_exit={result.returncode}")
    print(f"installed_package_binary_exists={(package / 'bin/codex').exists()}")
    print(f"current_target={current.readlink()}")
    print(f"current_target_exists={current.exists()}")
    print(f"visible_command_exists={visible.exists()}")
    if result.stderr:
        print(f"stderr={result.stderr.strip()}")
    if visible.exists():
        print(subprocess.check_output([str(visible), "--version"], text=True).strip())

On unmodified main:

installer_exit=127
installed_package_binary_exists=True
current_target=codex-home/packages/standalone/releases/0.142.5-aarch64-apple-darwin
current_target_exists=False
visible_command_exists=False

The final installer error is that the temporary install-bin/codex command is not found, despite the package binary existing. The fixture's version is 0.142.5; the defect is in the current install script's link construction rather than the CLI executable.

What is the expected behavior?

Resolve configured relative installation directories against the installer's initial working directory so package links and profile entries continue to work independently of later working directories.

Additional information

CODEX_HOME_DIR is used unchanged to derive STANDALONE_ROOT, then the relative release path is written as the target of current. A relative symlink target is resolved from the symlink's parent, not from the installer's working directory, producing the wrong path. BIN_DIR is likewise written as a relative path in the profile block.

A local candidate converts relative CODEX_HOME_DIR and BIN_DIR to absolute paths before deriving the other paths. The reproduction then exits 0, both links resolve, and the command prints codex-cli 0.142.5. Added fixture cases also cover daemon-only installation and sourcing the generated profile from a different directory; temporary paths include spaces. The complete installer suite passes 22 tests and 9 subtests, and sh -n and diff checks pass. Actual macOS and native release downloads were not tested.

Searched for relative CODEX_HOME/CODEX_INSTALL_DIR installer reports and did not find an equivalent issue. No external PR is requested, consistent with the contribution policy.

Lingua principale
Rust
Stelle
128k
Fork
20.1k
Merge medio
1m
PR unite (30g)
994

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.