Dyld: Library not loaded: /usr/local/opt/z3/lib/libz3.4.12.dylib

I want to run wasm-pack build --target web on a project locally but I keep getting

error: process didn't exit successfully: `rustc -vV` (signal: 6, SIGABRT: process abort signal)
--- stderr
dyld: Library not loaded: /usr/local/opt/z3/lib/libz3.4.12.dylib
  Referenced from: /usr/local/opt/llvm/lib/libLLVM.dylib
  Reason: image not found

I am on macOS, intel chip, and I have z3, zstd, and zlib installed under usr/local/opt directory. I have installed rust via homebrew.

Anyone ever faced such problem? I could not find a lot of information online about this error specifically.

If you are using rustc from rustup as that page tells you to, you should be using the LLVM version bundled with rustc itself, which doesn't depend on z3. In addition if you use rustup, rustc should be in a subdirectory of ~/.rustup/toolchains, not in /usr/local/opt. How did you actually install rust?

I checked I installed rust with homebrew. I uninstalled it and used https://rustup.rs/ to reinstall rust and I do not get the error anymore. Thank you!