-
Notifications
You must be signed in to change notification settings - Fork 12
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
Support for multi-root workspaces #590
Comments
What would you expect it to do instead? |
I would expect it works exactly as it working now, but as it were N different instances of vscode, one for each root. So if I have roots a,b,c and each one having its own .envrc file, when I open a terminal in directory a, only a/.envrc is loaded, if I open a terminal in directory b, only b/.envrc is loaded, and so on. I can achieve the same results but opening a different instance of vscode for each a, b and c but it defeats the purpose of a multi root workspace. |
The settings to the environment need to happen for the whole workspace so I don't think that's possible. I'm curious though, what would you say is the purpose of a multi-root workspace? Because to me it's having a consistent setup that happens to span several folders, and from that perspective, what you're describing would "defeat the purpose" of multi-root workspaces. |
If you are working on a project that have several components like servers and clients for example, it makes sense to have different directories (and several repos) for each one of them and working on them separately, but sometimes you need to work on several of them at the same time if you are full stack dev, or even a solo dev. In that scenario a multi-root workspace makes sense to have the projects open in the same vscode instance instead of switching instances. In this case you would want to have a .envrc for each component, and keep this configuration when opening the multi-root workspace. If you have a single .envrc you are forced to share settings across components, leading to all kinds of issues. |
Interesting, thank you for sharing. What you're asking for isn't possible with vscode, but I should document how this extension behaves and why and that this is expected. Also have you looked at #553? I haven't managed to release it yet but you should be able to find its built extension in the PR actions. It should allow you to change which envrc should be loaded while working on a project like yours. Would that help any? |
Thank you for developing the plugin and taking the time to evaluate this suggestion.
That's an interesting statement given the little knowledge I have shared about my issue (which actually has nothing to do with code), but certainly it is not the place to argue about this. #553 is not ideal for my use case but helps. Thanks again for your time. |
From my perspective, that could easily be achieved with single-root workspaces, although it could require some clever symlinking.
Now that's what I would call a bummer.
To play the devil advocate's here it does make sense in theory. Even if you're a full-stack/solo dev you should be able to develop/prototype the frontend aside from the backend. If you have closely related microservices you should be able to stub each other's behaviors in development. Boundaries and stuff. But it may very well be the case you're tasked with (hopefully legacy) tightly co-related projects (as in git repos). Or maybe you're a multi-tasker, possibly using gitlens workspaces feature to work on multiple branches simultaneously. Or... I guess what we all wanted to achieve is a way to multiplex a vscode window to work with more than one "project". Given vscode is unable to keep and restore window locations because electron didn't bother implementing the relevant APIs, having each window tied to a single project, when you work on more than one company/context, the window count to manage and move across virtual desktops and whatnots, every time vscode restarts, becomes quite painful. In my case each project has its own set of recommended extensions and these consume env vars such as PATH from direnv, and direnv uses |
Thanks for your thoughts @yangm97 I understand and agree with you 100%. You should be able to decouple stuff, and you should do it if you can. However, some projects demand simplicity and sometimes the added complexity to do the right thing is counterproductive. I was in one of those scenarios when I suggested this feature. A multi-root project was a practical solution at that moment. ¯\_(ツ)_/¯ |
We run into this issue as well because we have a system composed of multiple services and projects. At least for us the only place we really run into this problem is when using a jupyter notebook inside of vscode. I think if the direnv extension just had an additional command to be able to select which .envrc you want to source that would basically solve it. Would that be feasible? |
That was contributed in #553 and is available as the "Load .envrc file" command. |
There is already a solution to having vscode open terminals each leveraging the .envrc in each of the individual roots in a multi-root workspace. https://marketplace.visualstudio.com/items?itemName=joshx.workspace-terminals I think there is some confusion here in describing the desired outcomes. This extension handles pulling vscode+extensions into the context of a direnv loaded. direnv-vscode is pretty much required for WSL+flakes because there is no way to launch vscode in WSL with the context where it is launched from. Without this extension, everything needs to be a systemwide install. What I would like to see is a way to configure workspaces (specifically a .vscode-workspace file) to load a specified .envrc file. That would allow me to have a vscode profile with all of my c# extensions installed and create a multi-root workspace containing my c# projects. That .vscode-workspace file would live outside of any of the c# projects and avoid the manual step of launching "Load .envrc file". |
The plugin does't seem to work properly with multi-root workspaces.
When having multiple .envrc files, each one in each root, it detects only one .envrc file and ignores others.
The text was updated successfully, but these errors were encountered: