Preserve installer stderr when releasing the install lock (#59227)

## Why

Redirecting stderr on `exec` while closing the lock descriptor suppressed subsequent installer warnings, including the warning that an existing npm-managed Codex installation remains installed.

## What changed

Remove the stderr redirection from `release_install_lock` when closing file descriptor 9. Add a regression test asserting that a noninteractive install succeeds and emits the existing npm installation warning.

GitOrigin-RevId: 5a35ccd9bf62afb99cc949892ec724a01e2d9eee
This commit is contained in:
Eric Traut
2026-11-03 21:02:06 +00:00
committed by copyberry
parent 86cfa90536
commit 8960c363c6
2 changed files with 22 additions and 1 deletions
+1 -1
View File
@@ -743,7 +743,7 @@ release_install_lock() {
if [ "$lock_kind" = "mkdir" ]; then
rm -rf "$LOCK_DIR" 2>/dev/null || true
elif [ "$lock_kind" = "flock" ] || [ "$lock_kind" = "lockf" ]; then
exec 9>&- 2>/dev/null || true
exec 9>&-
fi
lock_kind=""
}
+21
View File
@@ -135,6 +135,27 @@ class InstallShTest(unittest.TestCase):
)
self.assertTrue(os.access(host_path, os.X_OK))
def test_noninteractive_install_warns_about_existing_npm_codex(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
root = Path(temp_dir)
archive, checksum, metadata = create_package_release(root)
(root / "bin").mkdir()
write_executable(root / "bin" / "codex", "#!/usr/bin/env node\n")
result, _ = run_installer_in(
root,
VERSION,
metadata_json=metadata,
archive_path=archive,
checksum_path=checksum,
force_macos=True,
)
self.assertEqual(result.returncode, 0, result.stderr)
self.assertIn(
"Leaving the existing npm-managed Codex installed", result.stderr
)
def test_releases_latest_installs_verified_package_by_default(self) -> None:
with tempfile.TemporaryDirectory() as temp_dir:
root = Path(temp_dir)