rust/editors/code/src
bors[bot] 8295a9340c
Merge #4329
4329: Look for `cargo`, `rustc`, and `rustup` in standard installation path r=matklad a=cdisselkoen

Discussed in #3118.  This is approximately a 90% fix for the issue described there.

This PR creates a new crate `ra_env` with a function `get_path_for_executable()`; see docs there.  `get_path_for_executable()` improves and generalizes the function `cargo_binary()` which was previously duplicated in the `ra_project_model` and `ra_flycheck` crates.  (Both of those crates now depend on the new `ra_env` crate.)  The new function checks (e.g.) `$CARGO` and `$PATH`, but also falls back on `~/.cargo/bin` manually before erroring out.  This should allow most users to not have to worry about setting the `$CARGO` or `$PATH` variables for VSCode, which can be difficult e.g. on macOS as discussed in #3118.

I've attempted to replace all calls to `cargo`, `rustc`, and `rustup` in rust-analyzer with appropriate invocations of `get_path_for_executable()`; I don't think I've missed any in Rust code, but there is at least one invocation in TypeScript code which I haven't fixed.  (I'm not sure whether it's affected by the same problem or not.) a4778ddb7a/editors/code/src/cargo.ts (L79)

I'm sure this PR could be improved a bunch, so I'm happy to take feedback/suggestions on how to solve this problem better, or just bikeshedding variable/function/crate names etc.

cc @Veetaha 

Fixes #3118.

Co-authored-by: Craig Disselkoen <craigdissel@gmail.com>
Co-authored-by: veetaha <veetaha2@gmail.com>
2020-05-08 10:11:19 +00:00
..
commands Preliminary refactoring of cargo.ts 2020-05-05 16:12:56 -07:00
cargo.ts Fix cargo not found on macos bug at vscode extension side 2020-05-05 16:12:56 -07:00
client.ts Merge #4145 2020-04-25 19:30:04 +00:00
config.ts Add master config for inlayHints to make disabling easy 2020-05-08 09:28:15 +02:00
ctx.ts Remove unnecessary async from vscode language client creation 2020-04-25 20:52:50 +03:00
inlay_hints.ts Add master config for inlayHints to make disabling easy 2020-05-08 09:28:15 +02:00
main.ts Fix cargo not found on macos bug at vscode extension side 2020-05-05 16:12:56 -07:00
net.ts Rewrite auto-update 2020-03-19 09:04:59 +01:00
persistent_state.ts Rewrite auto-update 2020-03-19 09:04:59 +01:00
rust-analyzer-api.ts Extension types and rendering 2020-03-24 23:22:41 +01:00
source_change.ts Jump to sourceChanges in other files 2020-04-21 23:04:44 +02:00
status_display.ts Lean onto default implementation of configs 2020-04-02 12:47:58 +02:00
tasks.ts tasks.json Support 2020-04-22 17:05:04 -07:00
util.ts Fix cargo not found on macos bug at vscode extension side 2020-05-05 16:12:56 -07:00