Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,8 @@ also be set via lspconfig.

### Kate

Kate doesn't seem to include the typical cargo home (`<YOUR HOME DIRECTORY>/.cargo/bin`) directory
on the `PATH` it passes to rust-analyzer, so you'll need to pass the cargo home path to
`cargo-subspace` directly and provide an absolute path to the `cargo-subspace` binary itself.
In the example below, `<CARGO HOME>` should be substituted for an absolute path to the directory
in which your cargo binaries reside (usually, this is `<YOUR HOME DIRECTORY>/.cargo/bin`).

These settings should be specified in `Settings --> LSP Client --> User Server Settings`:
These settings should be specified in `Settings --> LSP Client --> User Server Settings`. Note the
`"useWorkspace": false` line; this is required!

```json
{
Expand All @@ -154,19 +149,16 @@ These settings should be specified in `Settings --> LSP Client --> User Server S
"useWorkspace": false,
"initializationOptions": {
"check": {
"allFeatures": true,
"overrideCommand": [
"<CARGO HOME>/cargo-subspace",
"--cargo-home=<CARGO HOME>",
"cargo-subspace",
"clippy",
"$saved_file"
]
},
"workspace": {
"discoverConfig": {
"command": [
"<CARGO HOME>/cargo-subspace",
"--cargo-home=<CARGO HOME>",
"cargo-subspace",
"discover",
"{arg}"
],
Expand All @@ -182,8 +174,6 @@ These settings should be specified in `Settings --> LSP Client --> User Server S
}
```

Note the `"useWorkspace": false` line; this is required!

## Troubleshooting/Debugging

If you run into trouble, please feel free to open an issue with the following:
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub struct CargoSubspace {
#[arg(long, short)]
pub verbose: bool,

/// The explicit path to the directory containing your cargo binaries. By default,
/// `cargo-subspace` will use the binaries on your `PATH`.
/// The explicit path to your cargo home. Typically, this is `$HOME/.cargo`. If this flag is not
/// included, `cargo-subspace` will use the binaries on your `PATH`.
#[arg(long, env = "CARGO_HOME")]
pub cargo_home: Option<PathBuf>,

Expand Down
10 changes: 4 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ impl Context {
}

fn toolchain_command(&self, command: &str) -> Command {
let mut cmd = Command::new(command);

if let Some(cargo_home) = self.cargo_home.as_ref() {
cmd.env("PATH", cargo_home);
Command::new(cargo_home.join("bin").join(command))
} else {
Command::new(command)
}

cmd
}
}

Expand Down Expand Up @@ -189,7 +187,7 @@ fn discover(ctx: &Context, discover_args: DiscoverArgs, manifest_path: FilePath<
cmd.manifest_path(manifest_path);

if let Some(cargo_home) = ctx.cargo_home.as_ref() {
cmd.cargo_path(cargo_home.join("cargo"));
cmd.cargo_path(cargo_home.join("bin/cargo"));
}

if let Some(target_triple) = target_triple {
Expand Down