VSCode error: linker `cc` not found | = note: No such file or directory (os error 2)
⚓ Rust 📅 2026-04-07 👤 surdeus 👁️ 7I found these 2 threads here and here, but my problem is specific to vscode. I can compile and run test using cargo build and cargo test in terminal without a problem, and the program cc can be found at /usr/bin/cc.
$ which cc
/usr/bin/cc
My problem is when each time I edit and change the source code e.g. test case, I need to explicitly execute the command cargo test in terminal. Then, pressing Run test button inside vscode IDE would work. Otherwise, vscode will throw error: linker cc not found.
This problem seems to me that vscode does not sourcde .profile, where there exist the steps to activate rust env setting.
# rust env
. "$HOME/.cargo/env"
export LIBCLANG_PATH=/usr/lib/llvm-21/lib/libclang.so
However, I am not sure where to configure to fix this error in vscode. I attempted to add related setting to ~/.config/Code/User/settings.json, but it does not work.
"terminal.integrated.env.linux": {
"PATH": "${env:PATH}:/usr/bin/",
"LIBCLANG_PATH": "/usr/lib/llvm-21/lib/libclang.so"
}
How should I fix this error? Thanks.
2 posts - 2 participants
🏷️ Rust_feed