Home
Support Forums

Rust build not working due to missing /usr/bin/clang

Hi, I’m having issues building a rust wasm project.
My site name is: mr-nugget.netlify.app

When running the following build script:

rustup toolchain install nightly
rustup override set nightly
rustup target add --toolchain nightly wasm32-unknown-unknown
cargo build --release --target-dir=public --target=wasm32-unknown-unknown

I get the following error:

12:31:12 PM: Build ready to start
12:31:14 PM: build-image version: 3bcb38c35508b42e9121d4badfe6d8c66fd7a3f0
12:31:14 PM: build-image tag: v4.3.2
12:31:14 PM: buildbot version: f76d0586731616514ae5f22a8e90e34a01fbd211
12:31:14 PM: Fetching cached dependencies
12:31:14 PM: Starting to download cache of 88.4KB
12:31:14 PM: Finished downloading cache in 55.63149ms
12:31:14 PM: Starting to extract cache
12:31:14 PM: Finished extracting cache in 7.60686ms
12:31:14 PM: Finished fetching cache in 63.626017ms
12:31:14 PM: Starting to prepare the repo for build
12:31:14 PM: Preparing Git Reference pull/5/head
12:31:15 PM: Parsing package.json dependencies
12:31:16 PM: Starting build script
12:31:16 PM: Installing dependencies
12:31:16 PM: Python version set to 2.7
12:31:17 PM: Downloading and installing node v16.11.0...
12:31:17 PM: Downloading https://nodejs.org/dist/v16.11.0/node-v16.11.0-linux-x64.tar.xz...
12:31:17 PM: Computing checksum with sha256sum
12:31:17 PM: Checksums matched!
12:31:20 PM: Now using node v16.11.0 (npm v8.0.0)
12:31:21 PM: Started restoring cached build plugins
12:31:21 PM: Finished restoring cached build plugins
12:31:21 PM: Attempting ruby version 2.7.2, read from environment
12:31:22 PM: Using ruby version 2.7.2
12:31:22 PM: Using PHP version 8.0
12:31:22 PM: Started restoring cached go cache
12:31:22 PM: Finished restoring cached go cache
12:31:22 PM: go version go1.16.5 linux/amd64
12:31:22 PM: go version go1.16.5 linux/amd64
12:31:22 PM: Installing missing commands
12:31:22 PM: Verify run directory
12:31:24 PM: ​
12:31:24 PM: ────────────────────────────────────────────────────────────────
12:31:24 PM:   Netlify Build                                                 
12:31:24 PM: ────────────────────────────────────────────────────────────────
12:31:24 PM: ​
12:31:24 PM: ❯ Version
12:31:24 PM:   @netlify/build 18.13.12
12:31:24 PM: ​
12:31:24 PM: ❯ Flags
12:31:24 PM:   baseRelDir: true
12:31:24 PM:   buildId: 616458c099c48c0007cedac8
12:31:24 PM:   deployId: 616458c099c48c0007cedaca
12:31:24 PM: ​
12:31:24 PM: ❯ Current directory
12:31:24 PM:   /opt/build/repo
12:31:24 PM: ​
12:31:24 PM: ❯ Config file
12:31:24 PM:   No config file was defined: using default values.
12:31:24 PM: ​
12:31:24 PM: ❯ Context
12:31:24 PM:   deploy-preview
12:31:24 PM: ​
12:31:24 PM: ────────────────────────────────────────────────────────────────
12:31:24 PM:   1. Build command from Netlify app                             
12:31:24 PM: ────────────────────────────────────────────────────────────────
12:31:24 PM: ​
12:31:24 PM: $ bin/build-netlify
12:31:24 PM: info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
12:31:24 PM: info: latest update on 2021-10-11, rust version 1.57.0-nightly (41dfaaa3c 2021-10-10)
12:31:24 PM: info: downloading component 'cargo'
12:31:24 PM: info: downloading component 'clippy'
12:31:24 PM: info: downloading component 'rust-docs'
12:31:25 PM: info: downloading component 'rust-std'
12:31:25 PM: info: downloading component 'rustc'
12:31:26 PM: info: downloading component 'rustfmt'
12:31:26 PM: info: installing component 'cargo'
12:31:27 PM: info: installing component 'clippy'
12:31:27 PM: info: installing component 'rust-docs'
12:31:30 PM: info: installing component 'rust-std'
12:31:34 PM: info: installing component 'rustc'
12:31:40 PM: info: installing component 'rustfmt'
12:31:40 PM:   nightly-x86_64-unknown-linux-gnu installed - rustc 1.57.0-nightly (41dfaaa3c 2021-10-10)
12:31:40 PM: info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'
12:31:40 PM: info: checking for self-updates
12:31:40 PM: info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
12:31:40 PM: info: override toolchain for '/opt/build/repo' set to 'nightly-x86_64-unknown-linux-gnu'
12:31:40 PM:   nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.57.0-nightly (41dfaaa3c 2021-10-10)
12:31:41 PM: info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
12:31:41 PM: info: installing component 'rust-std' for 'wasm32-unknown-unknown'
12:31:45 PM:     Updating crates.io index
12:32:09 PM:  Downloading crates ...
12:32:10 PM:   Downloaded maybe-uninit v2.0.0
12:32:10 PM:   Downloaded bytemuck v1.7.2
12:32:10 PM:   Downloaded color_quant v1.1.0
12:32:10 PM:   Downloaded png v0.16.8
12:32:10 PM:   Downloaded miniz_oxide v0.3.7
12:32:10 PM:   Downloaded strum_macros v0.22.0
12:32:10 PM:   Downloaded unicode-xid v0.2.2
12:32:10 PM:   Downloaded quote v1.0.10
12:32:10 PM:   Downloaded cfg-if v1.0.0
12:32:10 PM:   Downloaded num-derive v0.3.3
12:32:10 PM:   Downloaded toml v0.5.8
12:32:10 PM:   Downloaded num-integer v0.1.44
12:32:10 PM:   Downloaded proc-macro2 v1.0.29
12:32:10 PM:   Downloaded unicode-segmentation v1.8.0
12:32:10 PM:   Downloaded num-traits v0.2.14
12:32:10 PM:   Downloaded hashbrown v0.9.1
12:32:10 PM:   Downloaded serde_derive v1.0.130
12:32:10 PM:   Downloaded serde v1.0.130
12:32:10 PM:   Downloaded glam v0.19.0
12:32:10 PM:   Downloaded macroquad_macro v0.1.7
12:32:10 PM:   Downloaded miniquad v0.3.0-alpha.37
12:32:10 PM:   Downloaded sapp-wasm v0.1.26
12:32:10 PM:   Downloaded sapp-linux v0.1.13
12:32:10 PM:   Downloaded num-rational v0.3.2
12:32:10 PM:   Downloaded syn v1.0.80
12:32:10 PM:   Downloaded strum v0.22.0
12:32:10 PM:   Downloaded smallvec v0.6.14
12:32:10 PM:   Downloaded ttf-parser v0.12.3
12:32:10 PM:   Downloaded quad-rand v0.2.1
12:32:10 PM:   Downloaded adler32 v1.2.0
12:32:10 PM:   Downloaded quad-snd v0.2.2
12:32:10 PM:   Downloaded libc v0.2.103
12:32:10 PM:   Downloaded macroquad v0.3.10
12:32:10 PM:   Downloaded lewton v0.9.4
12:32:10 PM:   Downloaded fontdue v0.5.2
12:32:10 PM:   Downloaded bitflags v1.2.1
12:32:10 PM:   Downloaded image v0.23.14
12:32:10 PM:   Downloaded quad-alsa-sys v0.3.2
12:32:10 PM:   Downloaded ogg v0.7.1
12:32:10 PM:   Downloaded ahash v0.4.7
12:32:10 PM:   Downloaded hound v3.4.0
12:32:10 PM:   Downloaded glam v0.14.0
12:32:10 PM:   Downloaded dasp_frame v0.11.0
12:32:10 PM:   Downloaded dasp_sample v0.11.0
12:32:10 PM:   Downloaded bumpalo v3.7.1
12:32:10 PM:   Downloaded audrey v0.3.0
12:32:10 PM:   Downloaded deflate v0.8.6
12:32:10 PM:   Downloaded num-iter v0.1.42
12:32:10 PM:   Downloaded crc32fast v1.2.1
12:32:10 PM:   Downloaded heck v0.3.3
12:32:10 PM:   Downloaded byteorder v1.4.3
12:32:10 PM:   Downloaded autocfg v1.0.1
12:32:10 PM:    Compiling autocfg v1.0.1
12:32:10 PM:    Compiling proc-macro2 v1.0.29
12:32:11 PM: error: linker `/usr/bin/clang` not found
12:32:11 PM:   |
12:32:11 PM:   = note: No such file or directory (os error 2)
12:32:11 PM: error: could not compile `proc-macro2` due to previous error
12:32:11 PM: warning: build failed, waiting for other jobs to finish...
12:32:11 PM: error: build failed
12:32:11 PM: ​
12:32:11 PM: ────────────────────────────────────────────────────────────────
12:32:11 PM:   "build.command" failed                                        
12:32:11 PM: ────────────────────────────────────────────────────────────────
12:32:11 PM: ​
12:32:11 PM:   Error message
12:32:11 PM:   Command failed with exit code 101: bin/build-netlify
12:32:11 PM: ​
12:32:11 PM:   Error location
12:32:11 PM:   In Build command from Netlify app:
12:32:11 PM:   bin/build-netlify
12:32:11 PM: ​
12:32:11 PM:   Resolved config
12:32:11 PM:   build:
12:32:11 PM:     command: bin/build-netlify
12:32:11 PM:     commandOrigin: ui
12:32:11 PM:     environment:
12:32:11 PM:       - REVIEW_ID
12:32:11 PM:     publish: /opt/build/repo/public
12:32:11 PM:     publishOrigin: ui
12:32:11 PM: Caching artifacts
12:32:11 PM: Started saving build plugins
12:32:11 PM: Finished saving build plugins
12:32:11 PM: Started saving pip cache
12:32:11 PM: Finished saving pip cache
12:32:11 PM: Started saving emacs cask dependencies
12:32:11 PM: Finished saving emacs cask dependencies
12:32:11 PM: Started saving maven dependencies
12:32:11 PM: Finished saving maven dependencies
12:32:11 PM: Started saving boot dependencies
12:32:11 PM: Finished saving boot dependencies
12:32:11 PM: Started saving rust rustup cache
12:32:16 PM: Finished saving rust rustup cache
12:32:16 PM: Started saving rust cargo registry cache
12:32:17 PM: Finished saving rust cargo registry cache
12:32:17 PM: Started saving rust cargo bin cache
12:32:17 PM: Finished saving rust cargo bin cache
12:32:17 PM: Started saving go dependencies
12:32:17 PM: Finished saving go dependencies
12:32:19 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:32:19 PM: Creating deploy upload records
12:32:19 PM: Failing build: Failed to build site
12:32:19 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:32:19 PM: Finished processing build request in 1m5.532674069s

I tried installing clang but the error persists, for some reason is not looking for it in the right location.

Hey there! I can see that you’ve since managed to deploy. Did you get to the bottom of this?

If not, it’s worth seeing what software is available within the build env: build-image/included_software.md at focal · netlify/build-image · GitHub

RE: Rust, there’s nothing installed by default. But, our build image,

  • Supports any version that rustup can install.

Hope this helps!

Hi @Scott thanks for the reply!

I managed to deploy but with a not ideal process: using GitHub actions and the netlify-cli, which is not a great experience since I don’t get the ability to automatically get the preview url in the pull request and such. So, not useful :frowning:

If you see the error is not exactly related to rust, but to clang, which is the LLVM c++ compiler. A dependency of the project is looking for clang in its usual place and it’s not finding it. Since I don’t have sudo access I can’t create a symlink to /usr/bin/clang if I do brew install llvm

I can do a quick call to show you what I’ve tried and what’s going on, let me know, thanks!

Hi @franciscotufro,

I don’t think you need sudo to use brew on Netlify. brew is already available in the build image (it’s in Alpha): Now in experimental alpha: homebrew access in the build image.

Mind giving it a try?

@hrishikesh thanks for your answer. I understand that I don’t need sudo to use brew, I can install clang, but i’m not able to symlink it to /usr/bin/clang which is where it’s being looked for.

Can clang be added to that location in the build image? Thanks!

Hi @franciscotufro,

That’s interesting. I’d expect brew to add the package where it needs to be by default. I’m not too familiar with the package you’re trying to use, but is /usr/bin/clang the location where it should be installed by default or can you change where the package is being looked for?

The reason I’m asking this is that, we can’t add additional packages to the build image at this stage. However, we would see if there’s something else you can try. But if not, I believe you’d have to rely on manual deploys using CLI or API.

Ok thanks, I’ll try to fix this through some environment variable or something. Thanks!