After installing Rust and configuring the Rust Language Server on VS Code, I wanted to run the tests directly from my IDE instead of typing cargo test
in my terminal. However I was getting the following error:
> Executing task: cargo test -- --nocapture test_fn <
zsh:1: command not found: cargo
The terminal process "/usr/bin/zsh '-c', 'cargo test -- --nocapture test_hex_to_u8'" failed to launch (exit code: 127).
Terminal will be reused by tasks, press any key to close it.
Even if your .zshrc
or .zprofile
are correctly configured with the path to the Rust environment, VSCode is popping a new task without using your login session, so it is not aware of your configuration!
To fix this, you need to provide the path in your .zshenv
file as well. If you don’t have a .zshenv
yet, you can just copy your existing configuration:
cp ~/.zprofile ~/.zshenv