I am trying to build a standalone application through which I can run Rust Clippy without needing to install it locally. Essentially, I want to run a command like cargo-clippy -- --message-format=json
through my application when a Rust project is uploaded to it.
What I've tried:
- I installed
cargo
locally using the instructions here - I forked the Clippy repo locally into a folder called
clippy_local
- I ran
cargo build
on the repo which created some exe binary files includingcargo-clippy
underclippy_local/target/debug/
(contents of thetarget
folder attached in screenshot below) - I copied this
cargo-clippy
exe into the tool binaries folder for my application
After this, the project compiles, but when I try to run Clippy through my tool, I get an error like below:
dyld[14510]: Library not loaded: '@rpath/librustc_driver-6ca1b5240144bf0b.dylib'
Referenced from: '/Users/<redacted>/repos/<redacted>/target/webapp/WEB-INF/classes/tools/clippy/cargo-clippy'
Reason: tried: '/usr/local/lib/librustc_driver-6ca1b5240144bf0b.dylib' (no such file), '/usr/lib/librustc_driver-6ca1b5240144bf0b.dylib' (no such file)
My app is running the following command internally to invoke Clippy:
/Users/<redacted>/repos/<redacted>/target/webapp/WEB-INF/classes/tools/clippy/cargo-clippy -- --message-format=json
I was guessing from the error that it has something to do with missing libraries/dependencies (apart from the cargo-clippy
exe). I have tried to copy all the contents of the target/debug
folder into my app as well, but the same error still persists.
So, I want to know what's going wrong and how I can build a Rust Clippy binary which I can then use to run Clippy from other applications?