If you are pulling Docker images from the Google Container Registery, you need gcloud installed, which on many systems is installed by default at ~/google-cloud-sdk/bin/docker-credential-gcloud.
This path is obviously not in the path by default. It seems that VS Code is not following any rc file for terminals to initialize a custom path. It would be nice if there was a good way to specify the PATH that gets used (if their already is, let me know can close out the ticket).
Why do you not want to add it to your regular PATH?
I have it added in my PATH in my zshrc file, but VS Code does not use that. On Ubuntu, I can actually install gcloud from a PPA and get it in the default PATH but on MacOS, there is no option to do that.
VS Code tries to read the environment variables from the default shell. What is process.env.SHELL in VS Code's dev tools (Help > Toggle Developer Tools)?
Also check if you have set zsh as your default shell, You can set it with:
chsh -s `which zsh`
My default is zsh, but it is not inheriting the $PATH variable from my .zshrc.

How is it initializing the environment variables for the default shell?
EDIT: It seems like it only gets my $PATH variable if I executes code-insiders directly from command line. If I use a DE to launch it, it gets the system default $PATH. So it would still be nice to be able to customize this within VS Code.
Is the terminal screenshot from the internal terminal when launching from the dock?
What's the error message you see that lets you conclude the PATH is incomplete?
Is the terminal screenshot from the internal terminal when launching from the dock?
No, it was an external one, but I get the same thing in the integrated terminal as well.
What's the error message you see that lets you conclude the PATH is incomplete?
Sorry, it took a bit to set this back up. Like I said, I had used a PPA to actually put gcloud in the system $PATH, but I put it back to where Google installs it (~/google-cloud-sdk). This is the error I get:
Setting up container for folder: /home/cbailey/dev/groot
Run: docker-compose -f /home/cbailey/dev/groot/docker-compose.yml -f /home/cbailey/dev/groot/.devcontainer/docker-compose.vscode.yml -f /home/cbailey/dev/groot/docker-compose.override.yml up -d
Creating network "groot" with the default driver
Building web
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 71, in main
command()
File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 127, in perform_command
handler(command, command_options)
File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 1080, in up
to_attach = up(False)
File "/usr/local/lib/python3.6/dist-packages/compose/cli/main.py", line 1076, in up
silent=options.get('--quiet-pull'),
File "/usr/local/lib/python3.6/dist-packages/compose/project.py", line 475, in up
svc.ensure_image_exists(do_build=do_build, silent=silent)
File "/usr/local/lib/python3.6/dist-packages/compose/service.py", line 358, in ensure_image_exists
self.build()
File "/usr/local/lib/python3.6/dist-packages/compose/service.py", line 1082, in build
platform=self.platform,
File "/usr/local/lib/python3.6/dist-packages/docker/api/build.py", line 251, in build
self._set_auth_headers(headers)
File "/usr/local/lib/python3.6/dist-packages/docker/api/build.py", line 313, in _set_auth_headers
credstore_env=self.credstore_env
File "/usr/local/lib/python3.6/dist-packages/docker/auth.py", line 96, in resolve_authconfig
authconfig, registry, store_name, env=credstore_env
File "/usr/local/lib/python3.6/dist-packages/docker/auth.py", line 127, in _resolve_authconfig_credstore
store = dockerpycreds.Store(credstore_name, environment=env)
File "/usr/local/lib/python3.6/dist-packages/dockerpycreds/store.py", line 25, in __init__
self.program
dockerpycreds.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH
Failed: docker-compose up
Command failed: docker-compose -f /home/cbailey/dev/groot/docker-compose.yml -f /home/cbailey/dev/groot/.devcontainer/docker-compose.vscode.yml -f /home/cbailey/dev/groot/docker-compose.override.yml up -d
Also, I verified manually adding it to my terminal.integrated.env.linux setting in my User Settings does not help either.
{
"terminal.integrated.env.linux": {
"PATH": "/home/cbailey/google-cloud-sdk:${env:PATH}"
},
}
We currently don't pick up terminal.integrated.env.* when running these commands. (@alexr00 Are tasks doing that?)
@AngellusMortis What do you get for PATH=/bin zsh -lic 'echo $PATH'? That's what VS Code runs to extract the environment variables (it does it in a single pass).
Yes, the terminal tasks uses does include environment variables set using terminal.integrated.env.*, but tasks does not expand those environment variables. So if you define MY_ENV_VAR using terminal.integrated.env.* then have a task that does echo %MY_ENV_VAR% it will work. But if your task does echo ${env:MY_ENV_VAR} then it will not expand.
What do you get for PATH=/bin zsh -lic 'echo $PATH'?
I get the expected value posted in the screenshot on the left above (because it logged me in and used my .zshrc).
I do not think the docker-compose command that gets ran to build the Docker images before Attaching VS Code is actually running the -i or the -l options though. Otherwise I would not get that stacktrace saying docker-credential-gcloud is not in my PATH.
You're right, we run: https://github.com/Microsoft/vscode/blob/master/src/vs/code/node/shellEnv.ts
That runs $SHELL with -lic and executes Node to print the entire environment to stdout from where we pick it up and set it for extensions and other processes. Somehow that fails to pick up your PATH.
/cc @joaomoreno for ideas.
@joaomoreno Could you log 'trace' level information in shellEnv.ts including the full command being executed and its output?
Ready to go on my branch: https://github.com/microsoft/vscode/commits/joao/next
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
@chrmarti So the both is just going to close this issue and #74 when there was absolutely no ask to us from the team? This is an issue that needs to be resolved. Docker builds are not using the user's configured shell $PATH or we cannot extend it, anyone have a a slightly customized Docker build will have trouble (including everyone that uses GCP, which is our use case).
@AngellusMortis Thanks for the reminder.
@joaomoreno I don't see the additional log messages in the latest insiders when starting with --log trace. I see the change is checked in. Anything in addition I need to do?
It should be on the main process.
@joaomoreno I see trace messages for the main process, but not these. This should always be triggered, shouldn't it?
It should yeah... :thinking:
@AngellusMortis Could you attach your .zshrc?
And could you run the following and attach its output?
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games /usr/share/code-insiders/code-insiders --verbose
As #74 is closed i'll come here for assistance..
/usr/local/bin is default on the PATH in any shell i use, but for some reason i get the same error described in https://github.com/microsoft/vscode-remote-release/issues/74#issuecomment-493092630.
I'm guessing that the code has hardcoded env? annoyingly in mac it's not possible to create files in /usr/bin or /bin, so i can't validate it.
@jakegt1 Where does /usr/local/bin come from? /etc/paths?
What is your shell and what do you get for: PATH=/bin $SHELL -lic 'echo $PATH'?
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
@Chrmarti Sorry for not responding to this..
My shell is fish.
Output of the command (but considering PATH=/bin doesn't work on fish, so env PATH=/bin $SHELL -lic 'echo $PATH')
/Users/jtorranc/.local/bin /opt/gradle/gradle-5.3.1/bin /Users/jtorranc/.nimble/bin /usr/local/opt/coreutils/libexec/gnubin /usr/local/opt/findutils/libexec/gnubin /opt/gradle/gradle-1.12/bin /Users/jtorranc/.local/bin /usr/local/opt/grep/libexec/gnubin /usr/local/opt/llvm@4/bin /usr/local/opt/findutils/libexec/gnubin /usr/local/bin /usr/bin /bin /usr/sbin /sbin
@jakegt1 Does it work when you start VS Code from a terminal window?
Could you start code --verbose and check what output you get in the terminal containing 'getUnixShellEnvironment'?
@chrmarti I have this problem as well, and it works when I start VC Code from a terminal window. I have /usr/local/bin in /etc/paths.
@mzeo Could you also start code --verbose and check what output you get in the terminal containing 'getUnixShellEnvironment'?
@chrmarti funnily enough, when i started it from my terminal.. it worked fine, and I could use containers as expected. You can define that as a workaround if you like.
Why it doesn't happen when starting vscode from the shortcut though is odd.
This occurs when docker was previously installed using homebrew. Running code from the terminal is a workaround.
@twhittock Where does homebrew place the addition of docker to $PATH?
docker is installed by homebrew into /usr/local/bin
PATH includes that location by default since 10.10 - homebrew doesn't mess with the global configuration, AFAIK.
/etc/paths looks like this (unmodified)
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
I never installed it using homebrew.
I'm hitting this too. I'm running Docker Desktop, shell is /bin/zsh, docker is in $PATH at /usr/local/bin/docker, which is also in /etc/paths. Launched via Finder/Docker, VS Code can't find Docker. It works if launch code from the terminal.
Hey @chrmarti, this issue might need further attention.
@AngellusMortis, you can help us out by closing this issue if the problem no longer exists, or adding more information.
If you see this when launching from the Mac's dock, but not when launching from the terminal:
process.argv.push('--verbose'); as the first line to /Applications/Visual Studio Code.app/Contents/Resources/app/out/main.js.F1 > Output: Focus on Output ViewLog (Main) from the combo box.getUnixShellEnvironment in that log and post all lines containing it here (make sure to obfuscate any private information).main.js.This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
Most helpful comment
I'm hitting this too. I'm running Docker Desktop, shell is
/bin/zsh, docker is in$PATHat/usr/local/bin/docker, which is also in/etc/paths. Launched via Finder/Docker, VS Code can't find Docker. It works if launch code from the terminal.