CodeBiker
CodeBiker

Reputation: 3253

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?

Upvotes: 9

Views: 9707

Answers (6)

Edoardo
Edoardo

Reputation: 5432

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

'code'command installation and uninstallation

Upvotes: -1

Cameron Seale
Cameron Seale

Reputation: 1

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

Upvotes: 0

bronson
bronson

Reputation: 5982

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.

Upvotes: 4

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

Upvotes: 29

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"

Upvotes: 2

CodeBiker
CodeBiker

Reputation: 3253

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.

Upvotes: 2

Related Questions