rust/crates
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
..
ra_arena Extract messy tree handling out of profiling code 2020-04-25 21:22:40 +02:00
ra_assists Simplify 2020-05-07 17:32:01 +02:00
ra_cfg Move feature desugaring to the right abstraction layer 2020-05-08 02:56:53 +02:00
ra_db Add fixture doc comment 2020-05-06 18:09:28 +02:00
ra_env use home crate instead of dirs 2020-05-07 12:06:44 -07:00
ra_flycheck pull function out into new crate ra_env; use in ra_flycheck as well 2020-05-05 16:12:56 -07:00
ra_fmt Introduce EffectExpr 2020-05-02 11:21:39 +02:00
ra_hir Remove HasVisibility implementation 2020-05-07 16:31:51 +03:00
ra_hir_def Remove HasVisibility implementation 2020-05-07 16:31:51 +03:00
ra_hir_expand Merge #4234 2020-05-02 10:30:49 +00:00
ra_hir_ty Fix usefulness check for never type 2020-05-06 17:59:27 +03:00
ra_ide Merge #4346 2020-05-07 16:29:01 +00:00
ra_ide_db Remove HasVisibility implementation 2020-05-07 16:31:51 +03:00
ra_mbe Rename ImplItem to AssocItem 2020-05-05 23:56:10 +08:00
ra_parser Fix parsing of blocks without { 2020-05-02 14:35:17 +02:00
ra_proc_macro proc_macro: add ability to log to stderr and view output in vscode 2020-04-23 01:57:02 +03:00
ra_proc_macro_srv Bump deps 2020-05-01 15:29:03 +03:00
ra_prof Simplify profiler impl (bubble up Option and shorten code 2020-04-26 00:55:49 +03:00
ra_project_model Merge #4329 2020-05-08 10:11:19 +00:00
ra_syntax Use more natural signature for Edit::apply 2020-05-05 23:23:29 +02:00
ra_text_edit Fix TODO 2020-05-06 13:21:49 +02:00
ra_tt Improve tt::Subtree debug print 2020-04-10 00:17:32 +08:00
rust-analyzer Merge #4296 2020-05-07 18:50:00 +00:00
stdx Move snake case method to heck 2020-05-03 21:35:21 +03:00
test_utils Allow fixture strings with unindented first line 2020-05-06 18:09:28 +02:00