Search code examples
pythonvisual-studio-codevimzsh

zsh: killed code . command on MacOs M1 chip monterey machine


So, I was trying to open vscode from terminal writing the following: code . so, I got the following

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

so, I tried to edit this file using vim sudo vim /usr/local/bin/code and changed the python to python3 and saved using :wq!

it didn't edit it as it's a read-only file, however, I open it as a root user who has a write-permission, giving me an error that

E166: Can't open linked file for writing,

and now when I try to do code . in the terminal it gives me

zsh: killed code .

and it's kinda stuck at this phase, now how can I open vscode from the terminal given that scenario?


Solution

  • code is a read-only file that already had been added to $PATH. It originally located in /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/ given that you are on a Mac machine.

    to fix

    /usr/local/bin/code: line 6: python: command not found

    you would need to change python to python3 using any editor giving code file the right permissions so you can edit it.

    so,

    1. sudo chmod 774 code now you have permission to edit it.
    2. change python to python3 and save the file.
    3. restart the terminal.

    and now, it should work fine, as it did for me.