简体   繁体   中英

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?

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.

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

在此处输入图像描述

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM