Metal devices are invisible inside sandbox on Apple Silicon, which causes false MLX failures

Open 💬 0 comments Opened Apr 6, 2026 by weypro

What version of Codex CLI is running?

latest

What subscription do you have?

plus

Which model were you using?

_No response_

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

_No response_

What issue are you seeing?

Inside the sandbox, Metal is not visible to the process. This makes MLX-based checks fail inside the sandbox even though they work in a normal terminal on the same machine.

What steps can reproduce the bug?

Repro in sandbox(codex):

mkdir -p .cache/swift-module .cache/xcode-home
CLANG_MODULE_CACHE_PATH="$PWD/.cache/swift-module" \
HOME="$PWD/.cache/xcode-home" \
swift -e 'import Metal
let all = MTLCopyAllDevices()
let defaultName = MTLCreateSystemDefaultDevice()?.name ?? "<nil>"
print("all_devices_count=\(all.count)")
print("default=\(defaultName)")'

Observed in sandbox:

all_devices_count=0
default=<nil>

Then:

python -c 'import mlx.core as mx; print("ok", mx.float32)'

Observed in sandbox:

  • MLX may abort during Metal init instead of failing gracefully.

Control result in a normal terminal on the same machine:

all_devices_count=1
default=Apple M5
ok mlx.core.float32

Expected:

  • Either expose Metal consistently, or clearly document that Metal is intentionally unavailable in sandboxed sessions.

What is the expected behavior?

_No response_

Additional information

https://github.com/ml-explore/mlx/issues/3148

View original on GitHub ↗