9

When I try to open VSCode from the command line with code ., I get the error ./MacOS/Electron: No such file or directory. How can I fix this?

6 Answers 6

29

If you're getting following Error:

/usr/local/bin/code: line 6: /usr/bin/python: No such file or directory
/usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory

Update python to python3 in following File:

/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code

Sign up to request clarification or add additional context in comments.

1 Comment

This helped me! I went to /Applications/Visual Studio Code.app/Contents/Resources/app/bin and opened the file with "nano code". In the sixth line I changed python to python3. Now it works like a charm.
4

To avoid changing VS Code files, you can add file named python to your path that just execs python3. For example, create a new file named /usr/local/bin/python:

#!/bin/sh

# work around missing `python` executable by calling `python3` 
exec python3 "$@"

Then chmod a+x /usr/local/bin/python

After quitting and relaunching your shell to ensure paths are re-hashed, everything should work again.

Comments

2

Open the file located at /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code and change python to /usr/bin/python.

Credit to joaomoreno for the solution.

Comments

2

For people who face the issue of -bash: /Applications/Visual Studio Code.app/Contents/Resources/app/bin/: is a directory despite following the solution by joaomoreno https://github.com/Microsoft/vscode/issues/3941, please add code at the end of the file path: alias code="/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code"

Comments

0

do you get this pop up when you try to install?

EACCES: permission denied, unlink '/usr/local/bin/code'

If so, what worked for me was uninstalling via the shift, cmd, P, dropdown in vscode and re-installing. hope that helps

Comments

-1

You can try and just let vscode uninstall / reinstall the command from the command palette, like this:

'code'command installation and uninstallation

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.