Long shot but worth it. I think I may have found my blocker for using #NixOS on my laptop/dev machines and am looking for help.
In short, I have multiple #Rust projects that build on the CLI just fine but not in VS Code/Rust Analyzer. I didn't spot this until very recently when I realized problems in my own code weren't being highlighted but compiled crates worked just fine.
Seems RA can't find some libraries but to the best of my abilities I've made those libraries available to the shell. I also launch code .
from the terminal so it should have the environment set up correctly without need for Nix-specific extensions.
It's been suggested I not use the code-fhs Nix package, but that means starting from scratch and fixing existing extensions which work.
Please don't suggest abandoning VS Code or substantially changing my accessible workflows unless you also have 12 extra hours per day for me. Also please don't suggest abandoning Linux entirely--this issue is NixOS, not Linux.
More context: discourse.nixos.org/t/rust-pro…
Rust project builds from the command line, but not in VS Code
Hey folks, seems like every time I think I’m starting to figure things out, I hit a new wrinkle. 🙂 I’ve been trying to move various projects to devshells.NixOS Discourse
andi242
in reply to Nolan Darilek • • •how do you make that dev shell available to vs code with all $PATH, etc? Unfortunately I have not much knowledge about Rust, but it appears that $PATH is somehow altered by vs code.
if that was stupid, please ignore 😄
Nolan Darilek
in reply to andi242 • • •code .
direnv takes care of the rest. Unfortunately, installing the direnv extension in VS Code doesn't appear to fix anything--adding that because someone just suggested it elsewhere. Thanks for the thoughts.andi242
in reply to Nolan Darilek • • •I'm not that familiar with vs code, but I believe that running code . from within the dev shell does not inherit the session itself, but I am not sure how you set up the dev shell.
I think direnv would read preconfigured .env/.envrc files and would not get the environment vars from the session.
There seems to be an extension for vs code named "Nix Environment Selector" that would let you select the dev shell file for an environment.
matthewrhone.dev/nixos-vscode-…
Setting Up nix-shell and Visual Studio Code to Interact
Matthew Rhone (Matthew Rhone dot Dev)Nolan Darilek
in reply to andi242 • • •Nolan Darilek
in reply to Nolan Darilek • • •Got a fix, in 2 parts:
cd .. && code myproject
.I guess my next question: is there a quick half-liner I can run to do something like
nuke_it_from_orbit && code .
to clear/reset the environment first?code .
from the terminal is pretty thoroughly in muscle memory at this point.Markus Wamser
in reply to Nolan Darilek • • •Nolan Darilek
in reply to Markus Wamser • • •