Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: for the @native release of the Node module, use the Rust version by default (#1084)

Michael Bolin63deb7c36937
diff --git a/codex-cli/bin/codex.js b/codex-cli/bin/codex.js
index 818b362700..1bfb9f5d5d 100755
--- a/codex-cli/bin/codex.js
+++ b/codex-cli/bin/codex.js
@@ -16,14 +16,23 @@
*/
import { spawnSync } from "child_process";
+import fs from "fs";
import path from "path";
import { fileURLToPath, pathToFileURL } from "url";
// Determine whether the user explicitly wants the Rust CLI.
-const wantsNative =
- process.env.CODEX_RUST != null
+
+// __dirname equivalent in ESM
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+
+// For the @native release of the Node module, the `use-native` file is added,
+// indicating we should default to the native binary. For other releases,
+// setting CODEX_RUST=1 will opt-in to the native binary, if included.
+const wantsNative = fs.existsSync(path.join(__dirname, "use-native")) ||
+ (process.env.CODEX_RUST != null
? ["1", "true", "yes"].includes(process.env.CODEX_RUST.toLowerCase())
- : false;
+ : false);
// Try native binary if requested.
if (wantsNative) {
@@ -63,10 +72,6 @@ if (wantsNative) {
throw new Error(`Unsupported platform: ${platform} (${arch})`);
}
- // __dirname equivalent in ESM
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = path.dirname(__filename);
-
const binaryPath = path.join(__dirname, "..", "bin", `codex-${targetTriple}`);
const result = spawnSync(binaryPath, process.argv.slice(2), {
stdio: "inherit",
@@ -78,10 +83,6 @@ if (wantsNative) {
// Fallback: execute the original JavaScript CLI.
-// Determine this script's directory
-const __filename = fileURLToPath(import.meta.url);
-const __dirname = path.dirname(__filename);
-
// Resolve the path to the compiled CLI bundle
const cliPath = path.resolve(__dirname, "../dist/cli.js");
const cliUrl = pathToFileURL(cliPath).href;
diff --git a/codex-cli/scripts/install_native_deps.sh b/codex-cli/scripts/install_native_deps.sh
index 00f355ca7d..5275627f6e 100755
--- a/codex-cli/scripts/install_native_deps.sh
+++ b/codex-cli/scripts/install_native_deps.sh
@@ -65,7 +65,7 @@ mkdir -p "$BIN_DIR"
# Until we start publishing stable GitHub releases, we have to grab the binaries
# from the GitHub Action that created them. Update the URL below to point to the
# appropriate workflow run:
-WORKFLOW_URL="https://github.com/openai/codex/actions/runs/15087655786"
+WORKFLOW_URL="https://github.com/openai/codex/actions/runs/15192425904"
WORKFLOW_ID="${WORKFLOW_URL##*/}"
ARTIFACTS_DIR="$(mktemp -d)"
diff --git a/codex-cli/scripts/stage_release.sh b/codex-cli/scripts/stage_release.sh
index fb641d35d9..9e251b9059 100755
--- a/codex-cli/scripts/stage_release.sh
+++ b/codex-cli/scripts/stage_release.sh
@@ -122,6 +122,7 @@ jq --arg version "$VERSION" \
if [[ "$INCLUDE_NATIVE" -eq 1 ]]; then
./scripts/install_native_deps.sh "$TMPDIR" --full-native
+ touch "${TMPDIR}/bin/use-native"
else
./scripts/install_native_deps.sh "$TMPDIR"
fi
@@ -130,11 +131,12 @@ popd >/dev/null
echo "Staged version $VERSION for release in $TMPDIR"
-echo "Test Node:"
-echo " node ${TMPDIR}/bin/codex.js --help"
if [[ "$INCLUDE_NATIVE" -eq 1 ]]; then
echo "Test Rust:"
- echo " CODEX_RUST=1 node ${TMPDIR}/bin/codex.js --help"
+ echo " node ${TMPDIR}/bin/codex.js --help"
+else
+ echo "Test Node:"
+ echo " node ${TMPDIR}/bin/codex.js --help"
fi
# Print final hint for convenience