oldergod
oldergod

Reputation: 15010

VSCode: 'code' function is preventing me from launching code from shell

I install Visual Studio Code for MacOS and installed the code command to the shell via the GUI.

enter image description here

Now, when I try to execute this command, I get the following error:

LSGetApplicationForInfo() failed with error -10814 while trying to determine the application with bundle identifier com.microsoft.VSCodeInsiders.

I have no idea what is the cause of this. I found that a function code has also been created and that if I remove it with unset code once, I can then run code in the shell and VSCode will launch correctly. Every reboot bring back this function though...

The code function is:

# type code
code is a function
code ()
{
    VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCodeInsiders" --args $*
}

What is the problem? What am I supposed to do here?

Upvotes: 3

Views: 1349

Answers (4)

oldergod
oldergod

Reputation: 15010

The code function was created from some other file I was using before even installing Visual Studio code and was then conflicting with the executable installed by the app under /usr/local/bin/code.

Upvotes: 1

Bitz
Bitz

Reputation: 1148

There is a known issue that occurs when you have an unintentionally outdated version where the bundle identifier is outdated.

Try manually updating VS Code to get started- just to be sure this isn't the issue.

Be sure you are running 1.11.2

code . shortcut fails on OSX

EDIT: Also, I still don't know why MS use negative signs in error codes. It's generally bad practice.

Upvotes: 0

razorsyntax
razorsyntax

Reputation: 359

This may relate to a conflict with another application.

A couple things to try:

  • Reinstall VSCode
  • Check for Updates in VSCode since they recently updated their bundler.

This is an issue I recently ran into and was able to resolve through reinstallation.

Upvotes: 0

kontiki
kontiki

Reputation: 40519

I have it installed in my Mac, and there is no alias. I do not need to unset anything. 'code' is just a script file, residing in `/usr/local/bin/code

It seems you have a conflict with some other application that has set an alias for 'code'. I recommend you look at all scripts that are run during shell startup:

~/.bash_profile
~/.bash_login
~/.profile
~/.inputrc
/etc/profile

It could also help if you post the content of your code alias

Upvotes: 1

Related Questions