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.

4 Answers 4


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 :-)

  • In my case (KDE Plasma + nautilus), just modifying /usr/share/applications/code.desktop (then update) did the trick.
    – Javier
    Feb 17, 2020 at 14:16
  • the script is to avoid to do it manually all the time :-) Feb 18, 2020 at 18:10
  • Indeed. I just wanted to point out that was enough. Actually I couldn't find mimeapps.list in /.local and there were no code.desktop in /usr mimeapps. That caused me half an hour of useless internet wandering.
    – Javier
    Feb 19, 2020 at 3:29
  • 2
    This behaviour by code is inacceptable. I don't want to open directories by default in vscode.
    – RichieHH
    Dec 28, 2020 at 14:42

Copy file:

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

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




  • This was enough for me too, a lot cleaner than the default answer
    – garzj
    Nov 25, 2022 at 8:30
  • Thank you, I spent just a half of a minute going through your solution and it works just nice, even though I'm not an ubuntu user - I'm a Manjaro Gnome user, so since it's the same Gnome - it works as it considered to do
    – Dominux
    Jan 22 at 8:20

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

xdg-mime default org.gnome.Nautilus.desktop inode/directory

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .