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

VS Code messes with Linux places paths. VS Code is opened instead of system path. #41037

Closed
jonagoldman opened this issue Jan 2, 2018 · 11 comments

Comments

Projects
None yet
5 participants
@jonagoldman
Copy link

commented Jan 2, 2018

The "Places" extension is a really popular extension that adds a menu for quickly navigating places in the system. It is activated by default on most Linux Gnome distributions.

After installing VS Code, anything opened using the "Places" extension opens VS Code instead of the default folder / path.

  • VSCode Version: 1.19.1-1 (official binary version)
  • OS Version: Antergos Linux 17.12

Steps to Reproduce:

  1. Install VS Code
  2. Make sure you have the "Places" extension activated
  3. Using the places menu in the top bar, open any location (Home, Documents, etc...)

screenshot from 2018-01-02 13-30-38

Actual result:
VS Code opens.

Expected result:
System path/folder/place is opened.

@bpasero

This comment has been minimized.

Copy link
Member

commented Jan 3, 2018

@Tyriar any clues?

@Tyriar

This comment has been minimized.

Copy link
Member

commented Jan 3, 2018

This happens because we register vscode as an opener of folders in the desktop file. If anyone knows a way to deprioritize or something we can do that but it would be too big of a regression to remove this feature from other, AFAICT behaving distros.

This is the "problem" line:

https://github.com/Microsoft/vscode/blob/fd08d32b40c8a9ff56777265bce3c385008c3cb1/resources/linux/code.desktop#L11

@Tyriar Tyriar assigned Tyriar and unassigned bpasero Jan 3, 2018

@Tyriar

This comment has been minimized.

Copy link
Member

commented Jan 3, 2018

As a workaround for our problem, you can open up the installed desktop file and remove inode/directory (every time VS Code updates).

@dertieran

This comment has been minimized.

Copy link

commented Feb 27, 2018

Just wanted to follow up on this issue because I get the same behavior.
It also happens when using xdg-open to open a directory (e.g. xdg-open ~).

I also set nautilus as the default for inode/directory

➜ xdg-mime default nautilus.desktop inode/directory

➜ xdg-mime query default inode/directory           
nautilus.desktop

but it still doesn't work.

Then I looked for the distribution-provided defaults for inode/directory

➜ cat /usr/share/applications/mimeinfo.cache | grep inode/directory
inode/directory=visual-studio-code.desktop;org.gnome.Nautilus.desktop;

and it seems the order here does matter, changing it to

inode/directory=org.gnome.Nautilus.desktop;visual-studio-code.desktop;

fixes the issue.

Sadly I'm not an expert in this field so I can't tell you if you can influence this or if this needs to be done after every update (I hope not because vs code is still registered).

It might be even a issue with gio (used here) and opening directories.
Because it works for text/plain as expected (it opens the file in gedit)

➜ xdg-mime query default text/plain                
gedit.desktop
 
➜ cat /usr/share/applications/mimeinfo.cache | grep text/plain     
text/plain=visual-studio-code.desktop;org.gnome.gedit.desktop;

➜ xdg-open ~/some.txt
@Tyriar

This comment has been minimized.

Copy link
Member

commented Feb 28, 2018

Copying over my response from #44344

This is happening due to this line in the .desktop file:

https://github.com/Microsoft/vscode/blob/master/resources/linux/code.desktop

Which tells the system (and nautilus) that VS Code knows how to open folders.

If anyone knows how to do this in such a way that it is marked as low priority I'd love to hear it, I'm not sure how to "fix" this without removing VS Code's integration for opening folders right now.

@dertieran

This comment has been minimized.

Copy link

commented Feb 28, 2018

I'm answering here instead of #44344.

@Tyriar I don't think it is really an issue with VS Code.
You are registering VS Code to for both text/plain and inode/directory
https://github.com/Microsoft/vscode/blob/fd08d32b40c8a9ff56777265bce3c385008c3cb1/resources/linux/code.desktop#L11

And as I mentioned before text/plain works as expected even though it is registered the same way.

I think this is a bug with inode/directory not using the default application but the "first one" registered for it.

I'm not sure where this should be reported instead, but I don't think you can do something about it (except for not registering inode/directory).

@dertieran

This comment has been minimized.

Copy link

commented Mar 1, 2018

Just verified this by installing another file manager (vifm).

➜ xdg-mime query default inode/directory                           
nautilus.desktop

➜ cat /usr/share/applications/mimeinfo.cache | grep inode/directory
inode/directory=vifm.desktop;visual-studio-code.desktop;org.gnome.Nautilus.desktop;

➜ xdg-open ~/Documents

Now it opens ~/Documents with vifm.
So it really takes the first entry instead of the default.

@Tyriar

This comment has been minimized.

Copy link
Member

commented Mar 1, 2018

Thanks for looking into it @dertieran, I'll close this off as you suggest since it looks like something in the OS is misbehaving

@Tyriar Tyriar closed this Mar 1, 2018

@Tyriar Tyriar removed the bug label Mar 1, 2018

@goodmami

This comment has been minimized.

Copy link

commented Mar 15, 2018

I know the issue is closed but the problem still affects me and I want to add some info here in case someone else stumbles upon this issue.

Note: I'm also using Gnome-shell (3.26.2) on Antergos, like the OP, and I don't recall having the problem on Ubuntu, so the problem is likely to affect Antergos and maybe Arch Linux.

The standard for default applications is to look for the first entry in one of several mimeapps.list files; if the first entry isn't available (uninstalled, etc.), the next is tried. Order does matter. On my machine, I have a ~/.config/mimeapps.list file, but it does not contain any entries for inode/directory, and there are no other mimeapps.list files that are checked. There are, however, mimeinfo.cache files, which are generated automatically from the .desktop files, meaning the default depends on the order they are automatically added (maybe by the timestamp of the .desktop file?). See the Arch wiki article about Default_applications#Desktop_entries for an explanation about the mimeinfo.cache files.

Changing the mimeinfo.cache file is only a temporary solution, since it gets regenerated. Instead, add an entry into the .config/mimeapps.list file (as described in this Antergos forum post), creating the file if necessary:

[Default Applications]
inode/directory = org.gnome.Nautilus.desktop

(or just the second line if there is already a [Default Applications] section; and change the .desktop file if you prefer a different default)

I think this is indeed a problem with the distribution and not VSCode

@goodmami

This comment has been minimized.

Copy link

commented Mar 18, 2018

Should be fixed in Antergos (see Antergos/antergos-packages#299)

Update your packages and test (but see here if you have trouble: https://forum.antergos.com/topic/9464/antergos-gnome-defaults-list)

@Tyriar

This comment has been minimized.

Copy link
Member

commented Mar 19, 2018

Thanks @goodmami!

@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 15, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.