4
  • I have a repository that has a Cargo.toml in sub_dir/Cargo.toml (Cargo.toml is not in repository root directory)
  • I'm using the repository from some of my computers. So I need to set up rust-analyzer.linkedProjects by each environment...

I want to avoid the configuration by machine. Do you know anything workaround?

crashmstr
  • 28,043
  • 9
  • 61
  • 79
tomlla
  • 519
  • 1
  • 6
  • 15

2 Answers2

9

to .vscode/settings.json

"rust-analyzer.linkedProjects": [
  "relateive/path/to/the/project/directory",
]

should add the path to Cargo.toml, like this.

"rust-analyzer.linkedProjects": [
  "relateive/path/to/the/project/directory/Cargo.toml",
]
jps
  • 20,041
  • 15
  • 75
  • 79
ozkanpakdil
  • 3,199
  • 31
  • 48
1

In .vscode/settings.json set the "rust-analyzer.linkedProjects" point to your Cargo.toml using an absolute path. That's the only way I got it to work eventhough all the resources online tend to tell you to use a relative path.

"rust-analyzer.linkedProjects": [
  "absolute/path/to/the/project/Cargo.toml"
],
mmatila
  • 76
  • 6
  • I had to use a absolute path as well. For example in your .vscode/settings.json you would put "backend/rust_project/Cargo.toml" for a a tree structure as backend->rust_project from the root folder. – Vraj Shah Apr 10 '23 at 02:44