Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 257
oldergod Avatar asked Mar 27 '26 23:03

oldergod


2 Answers

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

like image 57
kontiki Avatar answered Mar 31 '26 04:03

kontiki


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.

like image 44
oldergod Avatar answered Mar 31 '26 05:03

oldergod



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!