On shell startup I get error: no such file or directory: /Users/jeff/.docker/init-zsh.sh

Hi! When I boot my shell I get this error:

/Users/jeff/.zshrc:source:129: no such file or directory: /Users/jeff/.docker/init-zsh.sh

I can see that Docker Desktop added this to my .zshrc:

source /Users/jeff/.docker/init-zsh.sh || true # Added by Docker Desktop

And I can see that this file is indeed missing:

ls -a /Users/jeff/.docker
.                .token_seed.lock config.json      desktop-build    run
..               buildx           contexts         devenvironments  scout
.token_seed      cli-plugins      daemon.json      features.json

Any ideas? Thanks!

I donā€™t have init-zsh.sh on my Mac either. I donā€™t know why Docker would add it, but that is probably added only when Docker Desktop is installed. Have you tried to delete that line?

One thing I can imagine is that Docke provides a way to run that script optionally if that exists. Because of || true at the end, it will not break your zshrc but the error message will still appear. The correct way to make it optional would be something like this:

source /Users/jeff/.docker/init-zsh.sh 2>/dev/null || true # Added by Docker Desktop

which redirects the error message to /dev/null. Maybe I donā€™t have that line because I installed Docker Desktop many versions ago.

On second thought, hiding the error messages might not be the best idea as it would hide the error messages shown by commands actually running in an existing init-zsh script, but you could just create an empty script.

1 Like