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

Time:06-14

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?

CodePudding user response:

  1. Use shortcut keys "CTRL SHIFT P" in your vscode.
  2. Choose command "Shell Command: Install 'code' command in PATH"

enter image description here

  1. Restart the terminal for the new value to take effect. You'll be able to type 'code .' in any folder to start editing files in that folder.

You can refer to the document for more details.

CodePudding user response:

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.

  • Related