Skip to content

How to deal with crates that depend on cmake on macos #2626

@johnynek

Description

@johnynek

I am trying to use the zip crate. When I try to build after repinning and adding this dependency I get this error:

https://gist.github.com/johnynek/c53ea36910352d607eb6bf19612db3d9

Note, it has portions like:

CMAKE_TOOLCHAIN_FILE_aarch64-apple-darwin = None
CMAKE_TOOLCHAIN_FILE_aarch64_apple_darwin = None
HOST_CMAKE_TOOLCHAIN_FILE = None
CMAKE_TOOLCHAIN_FILE = None
CMAKE_GENERATOR_aarch64-apple-darwin = None
CMAKE_GENERATOR_aarch64_apple_darwin = None
HOST_CMAKE_GENERATOR = None
CMAKE_GENERATOR = None
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' from command line tools installation
cargo:warning=xcrun: error: unable to lookup item 'PlatformVersion' in SDK '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
CMAKE_PREFIX_PATH_aarch64-apple-darwin = None
CMAKE_PREFIX_PATH_aarch64_apple_darwin = None
HOST_CMAKE_PREFIX_PATH = None
CMAKE_PREFIX_PATH = None
CMAKE_aarch64-apple-darwin = None
CMAKE_aarch64_apple_darwin = None
HOST_CMAKE = None
CMAKE = None

So it seems to be saying that it can't find cmake. That makes sense, I didn't have cmake installed. But then I did brew install cmake and get the exact same error.

Finally I did:

sudo ln -s /opt/homebrew/bin/cmake /usr/local/bin/

and then reran the bazel build and it worked.

So, it seems that bazel rejects the cmake which is on my PATH in homebrew, but if I force it to also be in /usr/local/bin it works.

There are evidently two issues here:

  1. rules_rust isn't actually hermetic and is reaching out in the system to find some tools, such as cmake.
  2. it only reaches into certain places, not the user's path, which one might expect.

Could we have some way to declare the path to cmake in rules_rust setup or otherwise have a hermetic cmake toolchain? I don't think using the zip crate would be terribly esoteric.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions