I'm new to Rust and I'm about to start my very first project. I want to build something that requires web scraping and saw in the Cookbook that I can use the reqwest crate to perform HTTP requests.
Unfortunately, I got stuck immediately even before getting to write a single line of code
I added reqwest = "0.9.20" as a dependency in my Cargo.toml file and then ran cargo build.
The project fails to compile with the following error:
error: failed to run custom build command for `backtrace-sys v0.1.31`
Caused by:
process didn't exit successfully: `/Users/andresovela/rustdev/project_tracker/target/debug/build/backtrace-sys-28d20b1249f676c5/build-script-build` (exit code: 1)
Any ideas?
EDIT: I'm on macOS 10.14.6 (Mojave), latest stable Rust.
Do you have the normal MacOS non-rust development tools installed? As I recall backtrace-sys uses the system backtrace handler, meaning it needs to compile code native to the system for it to be able to work.
Note that this crate requires cc and ar to be present on Unix systems when libbacktrace is used (which is the default). For configuring C compilers see the cc crate documentation.
I did see that in the documentation but I don't really understand what can be going wrong there. I didn't see anything in the documentation about needing to have anything installed to be able to use cc.
Do you mean the "Command Line Tools" from Xcode? Because I do have them installed already.
Are cc and ar binaries that need to be installed? As far as I understand they're just some other Rust libraries that reqwest depends on. Shouldn't cargo manage the "installation" of those already?
So it's happening when it runs ar, with an error of malformed object, never seen this error before... To the Google!
So it seems this is not an uncommon error on Mac systems for any native code compilation (responses from everything from C to Haskell and more).
Some quick googling reveals:
Try running xcode-select --install to rebuild the pathing.
Make sure you don't have an alternative ar, only the official Apple one should be used, so make sure whereis ar or whence ar only resolves /usr/bin/ar and that you don't have another one ahead of it in the path like at /opt/local/bin/ar (this seems to be cause by broken migrations in macport or so).
Make sure you don't have cctools installed via brew, if you do remove them via brew uninstall -f cctools and run xcode-select --install again to repair the system.
Beyond that might need to wait for a Mac person to come around. ^.^;
For note, from what I was reading macports installs its own ar and runlib that don't work quite identically to the one from xcode, I saw many warnings about using macports on a system (where brew is recommended instead), and apparently even brew removed cctools a while back, can't install it anymore as xcode's should be used instead. I don't really know what either are (though from my guessing from usages macports seems like the BSD Ports package system and brew seems a lot like apt or yum?), so if you don't need macports it might be good to wipe it and setup xcode again fully.
Though considering it's working now, probably best not to touch anything, lol.