1

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 including cargo-clippy under clippy_local/target/debug/ (contents of the target folder attached in screenshot below) Contents of Clippy target folder
  • 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?

1
  • You should probably also copy some of the other files (and folders) in the same folder, such as clippy-driver Commented Jan 24, 2023 at 14:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.