Opened 5 months ago

Last modified 6 weeks ago

#73262 new defect

xcodebuild fails with "IDEDownloadableMetalToolchainCoordinator: Failed to remount the Metal Toolchain"

Reported by: essandess (Steve Smith) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: reneeotten (Renee Otten), markmentovai (Mark Mentovai), breun (Nils Breunese), Dave-Allured (Dave Allured)
Port: py-pytorch

Description (last modified by ryandesign (Ryan Carsten Schmidt))

I follow the new instructions at TahoeProblems#MetaltoolchainisnolongerbundledinXcode and see this mount permission failure trying to use Xcode MetalToolchain with user macports:

IDEDownloadableMetalToolchainCoordinator: Failed to remount the Metal Toolchain: The file “68d8db6212b48d387d071ff7b905df796658e713” couldn’t be opened because you don’t have permission to view it.

Compiling with xcrun throws the error (specifics below):

error: cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain

These are the error that’s thrown when following the commands at TahoeProblems#MetaltoolchainisnolongerbundledinXcode and trying to build metal using user macports:

This works:

$ xcodebuild -downloadComponent MetalToolchain

This (sort of?) fails:

$ sudo --user=macports xcodebuild -showComponent MetalToolchain
2025-11-21 07:26:16.297 xcodebuild[57545:4285032]  IDEDownloadableMetalToolchainCoordinator: Failed to remount the Metal Toolchain: The file “68d8db6212b48d387d071ff7b905df796658e713” couldn’t be opened because you don’t have permission to view it.
2025-11-21 07:26:16.419 xcodebuild[57545:4285030]  IDEDownloadableMetalToolchainCoordinator: Failed to remount the Metal Toolchain: The file “68d8db6212b48d387d071ff7b905df796658e713” couldn’t be opened because you don’t have permission to view it.
2025-11-21 07:26:16.426 xcodebuild[57545:4285030]  IDEDownloadableMetalToolchainCoordinator: Failed to remount the Metal Toolchain: The file “68d8db6212b48d387d071ff7b905df796658e713” couldn’t be opened because you don’t have permission to view it.
Asset Path: /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/68d8db6212b48d387d071ff7b905df796658e713.asset/AssetData
Build Version: 17B54
Status: installed
Toolchain Search Path: /Users/username/Library/Developer/DVTDownloads/MetalToolchain/mounts/68d8db6212b48d387d071ff7b905df796658e713

This works:

$ sudo rm -f "$(sudo --user=macports getconf DARWIN_USER_TEMP_DIR)/xcrun_db"

Compiling with metal fails for user macports (this is a build command from PyTorch):

$ sudo -u macports bash -c 'cd /opt/local/var/macports/build/_opt_local_ports_python_py-pytorch/py313-pytorch/work/pytorch-v2.9.1/build/caffe2/aten/src/ATen/ ; xcrun metal -std=metal3.1 bfloat_inc.metal'
error: error: cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain

Versions:

$ xcodebuild -version ; xcrun -version
Xcode 26.1.1
Build version 17B100
xcrun version 72.

Please also see:

Change History (8)

comment:1 Changed 5 months ago by essandess (Steve Smith)

I've created a PR for the latest PyTorch version that I expect will build on the buildbots at https://github.com/macports/macports-ports/pull/30155

comment:2 Changed 5 months ago by essandess (Steve Smith)

This appears to be a cache issue. I got into the weeds of the discussion at #73008, and see that if I set xcrun_nocache=1 I am able to compile xcrun metal with user macports:

This works:

( cd /opt/local/var/macports/build/_opt_local_ports_python_py-pytorch/py313-pytorch/work/pytorch-v2.9.1/build/caffe2/aten/src/ATen/ ; sudo -u macports bash -c 'xcrun_nocache=1 xcrun metal -std=metal3.1 bfloat_inc.metal' )

Before, this, I unmounted the MetalToolchain path, although I am on an arm64 box and I'm not sure if that's necessary or not. I'll try a reboot to flush cache and see if this works with user macports.

$ diskutil eject $(xcodebuild -showComponent MetalToolchain | sed -E -n -e 's/^Toolchain Search Path: (.*)$/\1/p')
Disk /Users/username/Library/Developer/DVTDownloads/MetalToolchain/mounts/68d8db6212b48d387d071ff7b905df796658e713 ejected

$ sudo -u macports xcodebuild -showComponent MetalToolchain
2025-11-21 08:37:07.719 xcodebuild[63109:4523360]  IDEDownloadableMetalToolchainCoordinator: Metal Toolchain unable to refresh cache with error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"
2025-11-21 08:37:07.735 xcodebuild[63109:4523360]  IDEDownloadableMetalToolchainCoordinator: Metal Toolchain unable to refresh cache with error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied"
Asset Path: /System/Library/AssetsV2/com_apple_MobileAsset_MetalToolchain/68d8db6212b48d387d071ff7b905df796658e713.asset/AssetData
Build Version: 17B54
Status: installed
Toolchain Identifier: com.apple.dt.toolchain.Metal.32023
Toolchain Search Path: /opt/local/var/macports/home/Library/Developer/DVTDownloads/MetalToolchain/mounts/68d8db6212b48d387d071ff7b905df796658e713

$ sudo -u macports xcodebuild -find metal
/opt/local/var/macports/home/Library/Developer/DVTDownloads/MetalToolchain/mounts/68d8db6212b48d387d071ff7b905df796658e713/Metal.xctoolchain/usr/bin/metal

$ sudo -u macports xcrun --find metal
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal

$ sudo -u macports xcrun metal --version
error: error: cannot execute tool 'metal' due to missing Metal Toolchain; use: xcodebuild -downloadComponent MetalToolchain

$ sudo -u macports bash -c 'xcrun_nocache=1 xcrun metal --version'
Apple metal version 32023.830 (metalfe-32023.830.2)
Target: air64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /opt/local/var/macports/home/Library/Developer/DVTDownloads/MetalToolchain/mounts/68d8db6212b48d387d071ff7b905df796658e713/Metal.xctoolchain/usr/metal/current/bin

Versions:

macOS 15.7.2 24G325 arm64
Xcode 26.1.1 17B100
Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 in reply to:  2 Changed 5 months ago by markmentovai (Mark Mentovai)

What version of MacPorts are you using? port version should report 2.11.6 (or later).

Replying to essandess:

This appears to be a cache issue. I got into the weeds of the discussion at #73008, and see that if I set xcrun_nocache=1 I am able to compile xcrun metal with user macports:

In that case, you can delete the xcrun cache:

% sudo rm -f "$(sudo --user=macports getconf DARWIN_USER_TEMP_DIR)/xcrun_db"

(or reboot, as you said you’d try.)

Versions:

macOS 15.7.2 24G325 arm64
Xcode 26.1.1 17B100

I think that’s an unusual combination. macOS 15 pairs with Xcode 16.

I know that Xcode 26 will run on a recent-enough macOS 15, but I don’t think that it’s a generally supported combination for MacPorts. I have a recollection of having tried to mix newer Xcodes with older macOS versions in the past, and things not going well in MacPorts—many ports make assumptions about version concordance that this would violate.

Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:4 Changed 5 months ago by jmroot (Joshua Root)

The issue tends to be not having the SDK for the OS version you're building on, rather than the Xcode version as such.

comment:5 Changed 5 months ago by essandess (Steve Smith)

I confirm that a reboot fixes this issue. I'd suggest adding that step to the instructions at TahoeProblems#MetaltoolchainisnolongerbundledinXcode

Also on MacPorts 2.11.6. And Sequoia is an "older macOS"?!

Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:6 in reply to:  5 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)

Steve, please remember to use TracLinks.

Replying to essandess:

I confirm that a reboot fixes this issue. I'd suggest adding that step to the instructions at TahoeProblems#MetaltoolchainisnolongerbundledinXcode

You can edit the wiki yourself.

comment:7 in reply to:  5 Changed 5 months ago by jmroot (Joshua Root)

Replying to essandess:

And Sequoia is an "older macOS"?!

The point in context was about relative age, so yes, it's older than Xcode 26.

comment:8 Changed 6 weeks ago by Dave-Allured (Dave Allured)

Cc: Dave-Allured added
Note: See TracTickets for help on using tickets.