Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Understand how to use Visual Studio Code on Windows and Linux for C++ development with conda/mamba/pixi #22

Open
traversaro opened this issue Feb 19, 2024 · 4 comments

Comments

@traversaro
Copy link
Contributor

At the moment, everyone in the lab using Visual Studio Code with conda/mamba is actually launching code in a terminal in which the environment has been activated. This is cumbersome and complex, it would be great to find an alternative.

Past research on the topic:

@traversaro
Copy link
Contributor Author

Ok, I think I found a way, still not super ergonomic but it is working:

  • Install https://marketplace.visualstudio.com/items?itemName=corker.vscode-micromamba
  • Ctrl+Shift+P --> Micromamba: Activate environment by path --> Pass the folder of the environment you want to open, if you just created it via mamba C:\Users\straversaro\AppData\Local\miniforge3\envs\<name> or C:\Users\straversaro\AppData\Local\mambaforge\envs\<name> on Windows, and /home/traversaro/miniforge3/envs/<name> or /home/traversaro/mambaforge/envs/<name> on Linux
  • Then I configured a CMake project with "[Unspecified]", and all the CMake dependencies have been found correctly.

@traversaro
Copy link
Contributor Author

traversaro commented May 9, 2024

This comment prefix-dev/pixi#411 (comment) is related. They refer to https://github.com/direnv/direnv-vscode, and indeed a possible workaround/workflow is to define a direnv's .envrc file that activates the conda environment?

@traversaro
Copy link
Contributor Author

I did some quick tests, on Linux the direnv extension work really well, even if you just installed direnv and you did not hooked it to your shell, CMake extensions then find all the C++ dependencies in the conda/pixi environment.

Instead on Windows I was not able to make direnv to work, apparently there are still some issues on the Windows side:

@giotherobot
Copy link
Contributor

Cool! We maybe want to update the suggested extensions to include this then.

@traversaro traversaro changed the title Understand how to use Visual Studio Code on Windows and Linux for C++ development with mamba Understand how to use Visual Studio Code on Windows and Linux for C++ development with conda/mamba/pixi May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants