Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code not opening with 'code' command

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?

like image 888
CodeBiker Avatar asked May 06 '26 00:05

CodeBiker


2 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

like image 84
Tobias Krainhöfner Avatar answered May 08 '26 21:05

Tobias Krainhöfner


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.

like image 29
bronson Avatar answered May 08 '26 20:05

bronson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!