Skip to content

Commit 109d513

Browse files
authored
Merge pull request #13575 from quarto-dev/bugfix/improve-arch
make arch detection more robust for virtualized envs like codex
2 parents 484baab + d53f899 commit 109d513

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

news/changelog-1.9.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ All changes included in 1.9:
4949

5050
- ([#13402](https://github.com/quarto-dev/quarto-cli/issues/13402)): `nfpm` (<https://nfpm.goreleaser.com/>) is now used to create the `.deb` package, and new `.rpm` package. Both Linux packages are also now built for `x86_64` (`amd64`) and `aarch64` (`arm64`) architectures.
5151
- ([#13528](https://github.com/quarto-dev/quarto-cli/pull/13528)): Adds support for table specification using nested lists and the `list-table` class.
52+
- ([#13575](https://github.com/quarto-dev/quarto-cli/pull/13575)): Improve CPU architecture detection/reporting in macOS to allow quarto to run in virtualized environments such as OpenAI's `codex`.

package/scripts/common/quarto

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,26 @@ fi
129129
if [[ $OSTYPE == 'darwin'* ]]; then
130130
# We cannot use uname to determine the _machine_ architecture:
131131
# https://github.com/quarto-dev/quarto-cli/issues/2420#issuecomment-1245768732
132-
FULLARCH="$(/usr/sbin/sysctl machdep.cpu.brand_string)"
133-
134-
if [[ $FULLARCH == *"Intel"* ]]; then
132+
# However, sysctl can return unexpected values in sandboxed/virtualized environments.
133+
# Use sysctl -n to get just the value, and check multiple possible patterns.
134+
FULLARCH="$(/usr/sbin/sysctl -n machdep.cpu.brand_string 2>/dev/null)"
135+
136+
if [[ $FULLARCH == *"Intel"* ]] || [[ $FULLARCH == *"Xeon"* ]] || [[ $FULLARCH == *"Core"* ]]; then
135137
ARCH_DIR=x86_64
136-
elif [[ $FULLARCH == *"Apple"* ]]; then
138+
elif [[ $FULLARCH == *"Apple"* ]] || [[ $FULLARCH == *"ARM"* ]]; then
137139
ARCH_DIR=aarch64
138140
else
139-
echo "quarto script failed: unrecognized architecture " ${FULLARCH}
140-
exit 1
141+
# Fallback to uname -m if sysctl doesn't give us recognizable output
142+
# This helps with sandboxed/virtualized environments
143+
UNAME_ARCH=$(uname -m)
144+
if [[ $UNAME_ARCH == "x86_64" ]]; then
145+
ARCH_DIR=x86_64
146+
elif [[ $UNAME_ARCH == "arm64" ]]; then
147+
ARCH_DIR=aarch64
148+
else
149+
echo "quarto script failed: unrecognized architecture. sysctl returned: '${FULLARCH}', uname -m returned: '${UNAME_ARCH}'"
150+
exit 1
151+
fi
141152
fi
142153

143154
else

0 commit comments

Comments
 (0)