Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode Shell Commands not retaining install status in $PATH after restart #42051

Closed
tragicdog opened this issue Jan 23, 2018 · 28 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X workbench-os-integration Native OS integration issues
Milestone

Comments

@tragicdog
Copy link

  • VSCode Version: Code 1.19.1 (0759f77, 2017-12-19T09:35:14.671Z)
  • OS Version: Darwin x64 17.3.0
  • Extensions:
Extension Author (truncated) Version
vscode-markdownlint Dav 0.12.1
PowerShell ms- 1.5.1
markdown-pdf yza 0.1.7

Steps to Reproduce:

  1. install shell command from VSCode.
  2. restart computer
  3. open terminal and type "code".

I launch most of my files from Terminal, I recently got a new laptop with 10.13.2 installed on it. Installed VSCode, and then installed shell commands through VSCodes command palette. Every time I restart my computer the 'code' command is not found. I have to launch VSCode from applications and then reinstall the shell commands.

@vscodebot vscodebot bot added the terminal General terminal issues that don't fall under another label label Jan 23, 2018
@Tyriar Tyriar added macos Issues with VS Code on MAC/OS X and removed terminal General terminal issues that don't fall under another label labels Jan 29, 2018
@Tyriar Tyriar assigned joaomoreno and unassigned Tyriar Jan 29, 2018
@joaomoreno
Copy link
Member

After you install it from Code, does it exist in /usr/local/bin/code? After you restart, is it still there?

@joaomoreno joaomoreno added the info-needed Issue requires more information from poster label Jan 30, 2018
@yerffejytnac
Copy link

yerffejytnac commented Jan 30, 2018

Same issue for me/after restart code was missing from /usr/local/bin.

This seems to work for now:

To manually add VS Code to your path:

cat << EOF >> ~/.bash_profile
# Add Visual Studio Code (code)
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

@joaomoreno
Copy link
Member

There must be something in your system removing the shortcut from /usr/local/bin. You should try to find out what that is.

@vscodebot vscodebot bot closed this as completed Feb 7, 2018
@vscodebot
Copy link

vscodebot bot commented Feb 7, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@sherlockwang
Copy link

I have a clean install macOS 10.13.3, and have the same issue. Is that a common issue on the latest macOS?

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Feb 26, 2018
@joaomoreno joaomoreno added this to the Backlog milestone Feb 26, 2018
@joaomoreno joaomoreno added the workbench-os-integration Native OS integration issues label Feb 26, 2018
@joaomoreno joaomoreno reopened this Feb 26, 2018
@dassennato
Copy link

Same issue here.
I have to install the code command every time I restart my new macbook, macOS 10.13.4

@loriculberson
Copy link

loriculberson commented Jun 13, 2018

Hope this helps you @sherlockwang @dassennato:
NOTE: This is slightly different from the path listed in the vs code documentation. The path listed below has:

  1. removed preceding \
  2. removed quotes " "
  3. added \ to escape the spaces in the path

export PATH=$PATH:/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin

Shout out to @nathanfu88 for the help solving this issue!

@benday
Copy link

benday commented Jun 14, 2018

I've been having this problem on my machine and I think I might have figured it out.

It looks like I've been running VS Code from ~/Downloads instead of from /Applications. Once I did that, the "code ." works just by editing .bash_profile.

Maybe this is a problem with the installer?

@illyay2017
Copy link

^ benday, THANK YOU for this comment. I realized this is exactly what I was doing too.

@dassennato
Copy link

@benday @illyay2017 Damn! same here. I moved the app to /Applications and it got fixed. Thanks!

@sublimeye
Copy link

@benday Thanks ... 🤦‍♂️

@danielnmai
Copy link

danielnmai commented Jul 23, 2018

@benday OMG I did not know this until today.... thank you. BUT the installer should have taken care of it (moving the app to the Applications folder).

@autodonncha
Copy link

Give @benday a job on the VSCode team.

@gebigoma
Copy link

gebigoma commented Sep 7, 2018

Nope, still doesn't work for me. I've tried all the above steps. Any other ideas?

@danielnmai
Copy link

@gebigoma I use MacOS High Sierra 10.13.6 and VS Code 1.26.1. Can you update yours to latest version, see if it works? After I updated VS Code, the problem went away (of course after I moved VS Code into Application folder).

@gebigoma
Copy link

gebigoma commented Sep 7, 2018

@danielnmai It's all updated, same MacOS version as yours but my VS code is 1.27.1, so even newer than your version.

@danielnmai
Copy link

There could be something with your terminal setup. I use iTerm2 and zsh shell, if this helps.

@cailinpitt
Copy link

Thanks, @benday. Same issue with me, was always running from Downloads instead of Applications. Moving Code to the Applications fixed it for me!

@theAndrewCline
Copy link

@benday Thanks so much, moving the application to the correct folder fixed it for me as well.

@sahni619
Copy link

Thanks @benday . You are my saviour :)

@sunali1
Copy link

sunali1 commented Oct 10, 2018

Thanks @benday!! Same with me

@matangover
Copy link

matangover commented Nov 27, 2018

I was having the same problem, but unlike @benday, I was running VS Code from /Applications (not from ~/Downloads). Turns out I still had the quarantine attribute set on VS Code -- probably because I had moved it from ~/Downloads to /Applications using mv instead of Finder. Only moving it using Finder removes the quarantine attribute.

To fix the issue, I followed the instructions in #48124 (comment) and ran:

xattr -dr com.apple.quarantine /Applications/Visual\ Studio\ Code.app

IMO since this seems to cause confusion, VS Code should show a warning if "Shell Command: Install 'code' command in PATH" is invoked when running from a read-only file system, as in Squirrel/Squirrel.Mac#186. Even better would be to offer the user to fix it for them.

@kevincai79
Copy link

Thanks @benday!!!

@kepi0809
Copy link

kepi0809 commented Jan 8, 2020

I've been having this problem on my machine and I think I might have figured it out.

It looks like I've been running VS Code from ~/Downloads instead of from /Applications. Once I did that, the "code ." works just by editing .bash_profile.

Maybe this is a problem with the installer?

thanks man, you saved me a lot of headaches 🙇

@sudo-ping-pong
Copy link

Thanks a ton @benday .

@ElPablo010
Copy link

@loriculberson That works for me, thanks!

@hackroid
Copy link

hackroid commented Apr 12, 2020

@matangover Thx! It works.
My vscode is located at /Applications but still act like starting from another weird place like ~/Downloads.

@ChristopherDalziel
Copy link

I've been having this problem on my machine and I think I might have figured it out.

It looks like I've been running VS Code from ~/Downloads instead of from /Applications. Once I did that, the "code ." works just by editing .bash_profile.

Maybe this is a problem with the installer?

THANK YOU MY GOD, I WAS SOMEHOW RUNNING MINE FROM THE TRASH.

br3ndonland added a commit to br3ndonland/dotfiles that referenced this issue Oct 11, 2020
ce224ae

- Improve formatting of printed comments
- Add `code`/`codium` command to PATH for macOS
- Add VSCodium as default distro: `CODE_DISTRO=${CODE_DISTRO:-"codium"}`
- Add error message if using Codespaces: Codespaces seems to have a
  limited version of the VSCode CLI that can't install extensions.

https://code.visualstudio.com/docs/setup/mac
microsoft/vscode#42051
https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces
br3ndonland added a commit to br3ndonland/dotfiles that referenced this issue Nov 6, 2020
ce224ae

- Improve formatting of printed comments
- Add `code`/`codium` command to PATH for macOS
- Add VSCodium as default distro: `CODE_DISTRO=${CODE_DISTRO:-"codium"}`
- Add error message if using Codespaces: Codespaces seems to have a
  limited version of the VSCode CLI that can't install extensions.

https://code.visualstudio.com/docs/setup/mac
microsoft/vscode#42051
https://docs.github.com/en/free-pro-team@latest/github/developing-online-with-codespaces
@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug macos Issues with VS Code on MAC/OS X workbench-os-integration Native OS integration issues
Projects
None yet
Development

No branches or pull requests