[SOLVED] Terminal in VS Code can't find Cargo

I've created my first small Rust program tonight. After trying PyCharm with a Rust plugin, I decided to try VS Code to see if that was any better. I've installed rust-analyzer, and opened my project folder, but it appears to have run into a problem.

It says:

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/home/biff/rx_test" && "cargo" "--version" failed: No such file or directory (os error 2)

And when I go to the TERMINAL tab, sure enough cargo is not there. But outside the terminal it works fine.

Inside the terminal I can see only a portion of the commands that my user can normally see in /usr/bin.

This is from the VS code terminal:

sh-5.1$ ls -l /usr/bin | wc
   1064    9747   70885

This is from a normal terminal under Linux Mint:

$ ls -l /usr/bin | wc
   2244   21117  142492

When I look at the files inside that terminal they appear to have been virtualised somehow:

-rwxr-xr-x  5 nfsnobody nfsnobody     1842 Dec 23 18:06  zmore
-rwxr-xr-x  5 nfsnobody nfsnobody     4577 Dec 23 18:06  znew
-rwxr-xr-x  4 nfsnobody nfsnobody   125976 Dec 23 18:06  zramctl
-rwxr-xr-x  4 nfsnobody nfsnobody   914456 Dec 23 18:06  zstd
lrwxrwxrwx  1 nfsnobody nfsnobody        4 Jan 29 22:30  zstdcat -> zstd
-rwxr-xr-x  5 nfsnobody nfsnobody     3869 Dec 23 18:06  zstdgrep
-rwxr-xr-x  5 nfsnobody nfsnobody       30 Dec 23 18:06  zstdless
lrwxrwxrwx  1 nfsnobody nfsnobody        4 Jan 29 22:30  zstdmt -> zstd

(outside that terminal they are owned by root).

So my question is how do I 'inject' cargo into that environment?

I'm running Linux Mint BTW.

thanks for any assistance.

How did you install VSCode?

Linux mint software manager

It seems that the package for vscode offered in the official mint repos is sandboxed using flatpak.

1 Like

Yes, that makes a lot of sense now. I'll try the official DEB.

Edit: Working much better now, many thanks for the swift response.