'"-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
Solution 1:[1]
I have already figured it out.
code .
instead of
. code
Solution 2:[2]
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
Solution 3:[3]
try this
cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF
Solution 4:[4]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | thatnicholascoder |
| Solution 2 | |
| Solution 3 | SothanaV |
| Solution 4 | Simon Liu |
