VS Code open directory instead of system file manager in Ubuntu 19.10

After upgraded to Ubuntu 19.10 I notice a stranger behaviour in code: if I double click a directory or a unit or right click a directory and try open the directory was open by code unless nemo or nautilus.

I install code by microsoft repo after add the repo to apt

I do not know if is a microsoft or gnome or ubuntu problem.

but this behaviour is not friendly.

I found a workaround to temporary solve the problem.

and be sure the inode/directory= was set to your file manager.


same for file ~/.config/mimeapps.list

then find the code desktop file.
mine is in /usr/share/applications/code.desktop
and change the row


then do
$ sudo update-desktop-database

to me this work but if vscode is updated all reset to the initial behaviour.

The /usr/share/applications/code.desktop is revert to initial value.

So to make all more quickly I write a script:

 sudo sed -i "s/inode/directory;//" /usr/share/applications/code.desktop
 sudo update-desktop-database

waiting for stable solution this may be acceptable


I have put the script above in an after-upgrade-code.sh and change in this manner (I put it inside PATH env):

UPDATED="$(tac /var/log/apt/history.log|sed '/End-Date/,$!d;/Start-Date/q'|tac|grep 'Upgrade.*code')"
if [[ ! -z $UPDATED ]]
  sudo sed -i "s/inode/directory;//" /usr/share/applications/code.desktop
  sudo update-desktop-database
exit 0

the I put it /etc/apt/apt.conf.d/100update:

Post-Invoke {"after-upgrade-code.sh";};

If last apt upgrade make change on code it will upgrade the code.desktop


I have done some test and I not be sure if the postinvoke script work fine: the problem is that I not sure history.log was updated at Post-Invoke time, so the script can do noting if history is not updated.

This is version 2 and this will be trigger:

CHECK="$(date '+%Y-%m-%d %H:%M')" 
CHECK="${CHECK:0:-1}.*upgrade code"
UPDATED=$(sudo grep "$CHECK" /var/log/dpkg.log)
#UPDATED="$(tac /var/log/apt/history.log|sed '/End-Date/,$!d;/Start-Date/q'|tac|grep 'Upgrade.*code')"
if [[ ! -z $UPDATED ]]
  sudo sed -i "s/inode/directory;//" /usr/share/applications/code.desktop
  sudo update-desktop-database
    echo "after-update-code is been executed"
    echo "after-update-code is been not executed"
exit 0

This: CHECK="$(date '+%Y-%m-%d %H:%M')" get the date time taking only minute.
This: ${CHECK:0:-1} cut minute unit and leave the ten so
the grep: grep "$CHECK" /var/log/dpkg.log
check if an ‘Code’ upgrade was done in less then ten minute and if verified try to update the code.desktop to avoid ‘Code’ will be use to open folder.

I have changed the hook trig:
sudo cat /etc/apt/apt.conf.d/100update
DPkg::Post-Invoke {"/home/leonardo/sviluppo/script/after-upgrade-code.sh";};


I have do a mistake writing the UPDATED wrong (UPTDATED), now is correct.


Last version work: I have verified 🙂

Answered By: Leonardo Saracini

Copy file:

cp /usr/share/applications/code.desktop ~/.local/share/applications/code.desktop

And edit ~/.local/share/applications/code.desktop:




Answered By: neon1ks

Check also the mimetype inode/mount-point:

xdg-mime query default inode/mount-point

if it’s empty the vscode could opens the mountpoint; set your filemanager to the default mimetype for mount point:

xdg-mime default org.kde.dolphin.desktop inode/mount-point
Answered By: zidagar

In gnome, you can use this command for set natural folder browser as default:

xdg-mime default org.gnome.Nautilus.desktop inode/directory
Answered By: Mohammad Ali Amini