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
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
1 Comment
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
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
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"
