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

Created on 10 Aug 2018  Â·  10Comments  Â·  Source: gfx-rs/gfx

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)
Metal blocker infrastructure user OSX bug

Most helpful comment

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.

All 10 comments

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

Yep

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

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.

Also, what happens if you just run xcrun metal?

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.

Yeah, I get the same results as @micouy

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

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

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.

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.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

grovesNL picture grovesNL  Â·  3Comments

Limeth picture Limeth  Â·  3Comments

kvark picture kvark  Â·  3Comments

kvark picture kvark  Â·  5Comments

Bastacyclop picture Bastacyclop  Â·  3Comments