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:
- Use shortcut keys "CTRL SHIFT P" in your vscode.
- Choose command "Shell Command: Install 'code' command in PATH"
- 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,
sudo chmod 774 code
now you have permission to edit it.- change
python
topython3
and save the file. - restart the terminal.
and now, it should work fine, as it did for me.