Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'xcrun: error: unable to find utility "metal", not a developer tool or in PATH' error when compiling 'gfx-backend-metal' #2309

Closed
expenses opened this issue Aug 10, 2018 · 11 comments

Comments

@expenses
Copy link
Contributor

When i try and run the quad example with cargo run --bin quad --features=metal I get the following error:

   Compiling cmake v0.1.32
   Compiling spirv_cross v0.10.0
   Compiling humantime v1.1.1
   Compiling gfx-backend-metal v0.1.0 (file:///Users/ashley/gfx/src/backend/metal)
error: failed to run custom build command for `gfx-backend-metal v0.1.0 (file:///Users/ashley/gfx/src/backend/metal)`
process didn't exit successfully: `/Users/ashley/gfx/target/debug/build/gfx-backend-metal-79a0feb3b5d52740/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=/Users/ashley/gfx/src/backend/metal/shaders
cargo:rerun-if-changed=/Users/ashley/gfx/src/backend/metal/shaders/blit.metal

--- stderr
xcrun: error: unable to find utility "metal", not a developer tool or in PATH
thread 'main' panicked at 'shader compilation failed', src/backend/metal/build.rs:49:13
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...

I'm fairly certain I've got all the xcode stuff installed, and my PATH is

/usr/local/opt/imagemagick@6/bin /Users/ashley/.cargo/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /opt/X11/bin /Library/Frameworks/Mono.framework/Versions/Current/Commands
  • GFX version: master
  • OS: macOS High Sierra Version 10.13.6 (17G65)
  • GPU: Intel Iris Plus Graphics 640 1536 MB
Default host: x86_64-apple-darwin

installed toolchains
--------------------

stable-x86_64-apple-darwin (default)
nightly-x86_64-apple-darwin

active toolchain
----------------

stable-x86_64-apple-darwin (default)
@grovesNL
Copy link
Contributor

Hi, could you verify that you've installed the Command Line Tools for Xcode? It should automatically add the necessary tooling to your path.

@expenses
Copy link
Contributor Author

Yep

xcode-select --install                                                                                                                                 (master *$=)
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

@grovesNL
Copy link
Contributor

Which path is printed with xcode-select --print-path?

You might need to try updating Xcode to be sure you have the latest macOS SDK.

@kvark
Copy link
Member

kvark commented Aug 10, 2018

Also, what happens if you just run xcrun metal?

@micouy
Copy link

micouy commented Aug 16, 2018

I'm having the same problem. Running xcrun metal also returns xcrun: error: unable to find utility "metal", not a developer tool or in PATH. xcode-select --print-path prints /Library/Developer/CommandLineTools on my computer.

@expenses
Copy link
Contributor Author

Yeah, I get the same results as @micouy

@micouy
Copy link

micouy commented Aug 16, 2018

Running xcode-select --switch /Applications/Xcode.app/Contents/Developer helped and the example compiles now.

@kvark
Copy link
Member

kvark commented Aug 17, 2018

Ok, so it's clear that this is just a misconfigured environment, and a solution is proposed. Closing then. Feel free to re-open!

@ghost
Copy link

ghost commented Dec 19, 2018

FWIW, on my clean installation of macOS Mojave, xcode-select --print-path was pointing to /Library/Developer/CommandLineTools as well.. Running sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer solved the problem, but I'm confused as to why this is necessary.

@wirelyre
Copy link

In case anyone else arrives at this issue from a search:

gfx requires both Xcode and the Xcode command line tools. Even if you have the command line tools installed, you still need Xcode.

Xcode is required for the complete macOS SDK (specifically the tools for compiling Metal shaders). The command line tools are required to use the SDK without opening the Xcode app.

You might have installed the command line tools before installing Xcode. For instance, you might have set up Homebrew first. The command line tools are pointing to an incomplete SDK, rather than the one you installed with Xcode.

How to fix

  1. Install Xcode from the Apple App Store.
  2. Install the command line tools with xcode-select --install. This might do nothing on your machine.
  3. If xcode-select --print-path prints /Library/Developer/CommandLineTools
  4. then run sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer.

KaareH added a commit to KaareH/gfx that referenced this issue Sep 7, 2020
Without the additional steps an error like `error: failed to run custom build command for `gfx-backend-metal v0.3.3`` may occur.

Additional steps copied from:
gfx-rs#2309 (comment)
bors bot added a commit that referenced this issue Sep 7, 2020
3369: Made instructions for macOS more clear r=grovesNL a=KaareZ

Without the additional steps, an error like `error: failed to run custom build command for `gfx-backend-metal v0.3.3`` may occur. Tested on a fresh install of macOS 10.15.6

Additional steps copied from comment:
#2309 (comment)


Co-authored-by: Kaare Hansen <kaare@gshansen.dk>
memco added a commit to memco/orca that referenced this issue Nov 17, 2023
When trying to install Orca on mac this message appeared: "xcrun: error: unable to find utility "metal", not a developer tool or in PATH" The instructions as explained here solve the issue: gfx-rs/gfx#2309 (comment)
@buzzm
Copy link

buzzm commented Feb 29, 2024

Running xcode-select --switch /Applications/Xcode.app/Contents/Developer fixed problem on ventura 13.2
Xcode 14.2
Build version 14C18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants