Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"-bash: //MacOS/Electron: No such file or directory" when using VS Code using " . code " shortcut

My IDE is VS Code I have been using it many times suddenly when I open vs code in my terminal

. code or source code

it displays error

-bash: //MacOS/Electron: No such file or directory
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

How do I fix this? I just want to get my normal vs code to work functional again just as before

like image 300
thatnicholascoder Avatar asked Mar 07 '26 11:03

thatnicholascoder


2 Answers

I visited https://vscode-docs.readthedocs.io/en/stable/editor/setup/

Afterwards, I copy and pasted the following onto a new line in my system ~/.zshrc file

code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

Don't forget to source ~/.zshrc after then restart terminal

Worked great, now I can run code . again for any folder/project

like image 198
Tiny Avatar answered Mar 09 '26 04:03

Tiny


For me, I didn't have a globally accessible python. Which is called in /usr/local/bin/code.

Since I'm using asdf I simply did asdf global python x.xx.x. If you are not using asdf perhaps perform brew install python.

like image 43
Simon Liu Avatar answered Mar 09 '26 03:03

Simon Liu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!