Skip to content

Commit 78ffcd9

Browse files
committed
Auto merge of #7460 - camsteffen:run-from-source, r=Manishearth
Add instructions to run from source changelog: none We often get messages on Zulip asking how to install and run Clippy from source. This adds instructions to the readme. I also added a note explaining that `cargo install --path . --force` is bad, which I just decided after some investigating. I use macOS. It would be nice to get some tests on other platforms to see if this is correct.
2 parents 54a20a0 + 6ef0cd7 commit 78ffcd9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

doc/basics.md

+42
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ the codebase take a look at [Adding Lints] or [Common Tools].
1414
- [lintcheck](#lintcheck)
1515
- [PR](#pr)
1616
- [Common Abbreviations](#common-abbreviations)
17+
- [Install from source](#install-from-source)
1718

1819
## Get the Code
1920

@@ -128,4 +129,45 @@ This is a concise list of abbreviations that can come up during Clippy developme
128129
general list can be found in the [rustc-dev-guide glossary][glossary]. Always feel free to ask if
129130
an abbreviation or meaning is unclear to you.
130131

132+
## Install from source
133+
134+
If you are hacking on Clippy and want to install it from source, do the following:
135+
136+
First, take note of the toolchain [override](https://rust-lang.github.io/rustup/overrides.html) in `/rust-toolchain`.
137+
We will use this override to install Clippy into the right toolchain.
138+
139+
> Tip: You can view the active toolchain for the current directory with `rustup show active-toolchain`.
140+
141+
From the Clippy project root, run the following command to build the Clippy binaries and copy them into the
142+
toolchain directory. This will override the currently installed Clippy component.
143+
144+
```terminal
145+
cargo build --release --bin cargo-clippy --bin clippy-driver -Zunstable-options --out-dir "$(rustc --print=sysroot)/bin"
146+
```
147+
148+
Now you may run `cargo clippy` in any project, using the toolchain where you just installed Clippy.
149+
150+
```terminal
151+
cd my-project
152+
cargo +nightly-2021-07-01 clippy
153+
```
154+
155+
...or `clippy-driver`
156+
157+
```terminal
158+
clippy-driver +nightly-2021-07-01 <filename>
159+
```
160+
161+
If you need to restore the default Clippy installation, run the following (from the Clippy project root).
162+
163+
```terminal
164+
rustup component remove clippy
165+
rustup component add clippy
166+
```
167+
168+
> **DO NOT** install using `cargo install --path . --force` since this will overwrite rustup
169+
[proxies](https://rust-lang.github.io/rustup/concepts/proxies.html). That is, `~/.cargo/bin/cargo-clippy` and
170+
`~/.cargo/bin/clippy-driver` should be hard or soft links to `~/.cargo/bin/rustup`. You can repair these by running
171+
`rustup update`.
172+
131173
[glossary]: https://rustc-dev-guide.rust-lang.org/appendix/glossary.html

0 commit comments

Comments
 (0)