-
Notifications
You must be signed in to change notification settings - Fork 552
Description
For anyone else that comes across this issue: This can be worked around by running code on the CLI.
Does this occur consistently? Yes
Repro steps:
- Close VS Code.
- Create a temporary project and open it in VS Code via the CLI:
mkdir -p ~/tmp && touch ~/tmp/docker-compose.yml && code ~/tmp/docker-compose.yml
- Verify that no error occurs.
- Close VS Code.
- Launch VS Code via Spotlight (⌘Space). It should re-open the same workspace automatically.
- After a few seconds, note the error occurs.
I'm using Docker Desktop 2.3.0.4, which comes with Engine 10.03.12.
docker commands work fine in the integrated terminal, including docker context ls --format="{{json .}}". It is located (from the integrated terminal):
$ type docker
docker is /usr/local/bin/dockerThis issue is probably occurring because Spotlight is providing a different (incomplete) environment that doesn't include /usr/local/bin on the PATH. Running code from the CLI works.
This works in the integrated terminal (configured to use Bash) because my environment files are sourced by the shell. However, since the extension is using /bin/sh, it won't be sourcing my .bashrc or .profile (which itself sources .bashrc, but only if the shell is BASH).
It's worth noting that even a plain sh launched with no environment works, which seems to indicate that the shell the extension launches has even less environment than that (!).
$ env -i sh -c 'docker --version'
Docker version 19.03.12, build 48a66213fe
$ env -i sh -c 'echo $PATH'
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.One last note: the macOS /etc/profile contains the following code:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fiRunning path_helper shows it also generates a PATH that would work here, so I'm guessing this is also not sourced by the sh run by the extension nor my environment-less sh above:
$ /usr/libexec/path_helper -s
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/puppetlabs/pdk/bin:<snip>"; export PATH;
This issue looks eerily similar to #2229 (closed due to not being reproducible).
Action: docker-context.initialize
Error type: 127
Error Message: Process 'docker context ls --format="{{json .}}"' exited with code 127
Error: /bin/sh: docker: command not found
Version: 1.5.0
OS: darwin
OS Release: 18.7.0
Product: Visual Studio Code
Product Version: 1.48.2
Language: en
Call Stack
ChildProcess.<anonymous> extension.bundle.js:3:173256
ChildProcess.emit events.js:203:13
maybeClose child_process.js:1021:16
Socket.<anonymous> child_process.js:430:11
Socket.emit events.js:203:13
Pipe.<anonymous> net.js:588:12
