VSCode/ VSCodium – Unable to resolve your shell environment…

(Am on a roll this week! After a long dry spell this is my 4th post in 3 days / 5th post this month…)

Since earlier this week whenever I’d launch VSCode or VSCodium (yes I started using the latter now) I’d always get a message saying its unable to resolve my shell environment. Like here.

I tracked it down to the fact that earlier this week I had started launching tmux by default on my desktops. Previously I would only launch it when SSHing into a machine but I figured it’s good to have it always launch on my desktops so I can easily connect to them from elsewhere. This was obviously interfering with VSCode. Interestingly, I had added the tmux launching code in .bash_profile so as to limit it to login sessions, but I guess VSCode launches bash as a login shell.

What to do here? Inspired by this GitHub issue I added the following line to my .bash_profile and disabled the bit that launches tmux.

This dumps the environment variables that are present when the shell is launched by VSCode. Here I found a variable VSCODE_RESOLVING_ENVIRONMENT that was set to 1. Boom, that’s my entry!

Before I go further, here’s how I currently launch tmux.

For certain machines it always launches, for the rest only if I am connecting via SSH. So I made one change:

Now the section that always launches it on certain machines also checks if the VSCODE_RESOLVING_ENVIRONMENT variable is empty and only then launches.

Sweet!

ps. I knew about VSCodium but didn’t really look into switching to it. Then I came across this blog post and that resonated with me so I started making the switch. I still have VSCode around coz a couple of the extensions I use only work with it, but I primarily use VSCodium otherwise. I recommend others too give it a shot. I also recommend the Night Owl theme, it’s available on both.