Obsidian doesn't use default browser on Ubuntu 22.04

I have the same issue, also on Ubuntu 22.04.3 LTS, also installed via snap (if that matters).

I tried the solution suggested by gregmuellegger but unfortunately it didn’t work for me. I also followed the link in his post and tried the gio approach.

Obsidian indeed does not seem to respect my default browser, and I do not have the same problem with other desktop clients.

2 Likes

I am having the same issue, and the fix listed above didn’t work for me either.

Same issue here. I am on Ubuntu 23.10, it worked fine on Ubuntu 22.04. If I click a link in obsidian (v1.5.3) it always opens the link in firefox, but I have set google chrome as default browser, see screenshot below for Ubuntu Settings (Settings->“Default Apps”):

Also there is no issue when using xdg-open from command line. So this seems to be a bug in obsidian since xdg-open opens the url in google-chrome (the default browser). And the fix provided by above by gregmuellegger:

xdg-mime default google-chrome.desktop x-scheme-handler/http
xdg-mime default google-chrome.desktop x-scheme-handler/https

did not fix the problem.

1 Like

+1 having same issue on Ubuntu 23.10. Opera is set as default browser but all links open in firefox

+1 Same issue, Ubuntu 22.04.3, Obsidian v1.5.3, installer v1.4.16

+1 Same issue here, please fix!

+1, same problem. Obsidian v1.5.3, Ubuntu 22.04.3

BTW, instead of setting default mime type you can just query to check what is set for specific types: xdg-mime query default x-scheme-handler/https

I’ve got google-chrome.desktop so my default settings are as I wanted.

1 Like

+1, same problem here too. Obsidian 1.5.3, Ubuntu 22.04.

$ xdg-mime query default x-scheme-handler/https
brave-browser.desktop
$ xdg-mime query default x-scheme-handler/http
brave-browser.desktop

Links open up in Firefox when the default is Brave.

Same happens to me, links open with Firefox instead of Edge.
Os: Fedora release 39
Obsidian: 1.5.8
Tried the steps above related to setting xdg-mime but didn’t work.

hi. same issue on Ubuntu 22.04

I have a similar issue and hopefully a useful observation.
Ubuntu 22.04 with xfce4
Obsidian 1.5.8 installed as AppImage (it was also an issue with v 1.5.3)
Firefox installed as snap
xdg-open works from the command line.
obsidian fails when clicking a web link with, “Failed to execute default browser”.

I did have this working previously by removing the firefox snap and installing the Mozilla deb - and MUCH fiddling to get the default browser set correctly.

Unfortunately an update for Ubuntu reinstalled the snap, even though I had “pinned” the deb and my default settings were left in disarray. So I am no longer fighting the firefox snap, just trying to get it to work with obsidian.

All my other apps launch web links successfully as expected EXCEPT zathura (pdf viewer).
It threw exactly the same error.
Adding “set sandbox none” to the zathura config file resolved the issue.

thunderbird for example just worked.

Maybe this is a separate issue?

Chris

Replying to my own post.
I tracked down my issue. It was not due to Obsidian, so a different issue to this thread, but hopefully this may help someone.

I set “terminal=true” in my desktop launcher file and found that when trying to launch a web link I was getting a permission denied error on the “Path” folder in the desktop file.

I was the owner of that folder and also part of the group.
The permissions were 700.
I changed the “Path” to my home folder which has permissions 755 and it started working.

Chris

please ensure then you have set the your Mozilla Firefox as a default browser.

Failed:

xdg-mime default google-chrome.desktop x-scheme-handler/http
xdg-mime default google-chrome.desktop x-scheme-handler/https

Failed:

  • Change default app and then change it back again

Success:

  • uninstall snap and install deb package.

Still same here… I’m so frustrated it’s insane. I have tried everything with xdg-mime, xdg-settings, .desktop files, update-alternatives and everything was set to Brave snap - still nothing. I uninstalled the Brave snap and installed the deb package, still nothing. I uninstalled every possible browser on my system and FINALLY I saw that a new browser windows opened up (not the new tab - which sucks equally as bad!). The cherry on the is present on the screenshot below. Somehow the browser window is considered to be an “Obsidian” process instead of running the actual app. Spaghetti must be strong with this one.

image

1 Like

Fix in my case

  1. If xdg-open works fine from console but obsidian still opens wrong browser, and you are using Snap you can use following hack to fix it:
  • ensure that ~/bin is on your PATH (echo $PATH) - or use different location
  • create ~/bin/xdg-open with following content:
#!/bin/bash

# fix for obsidian opening URLs in wrong browser
if [[ $SNAP_INSTANCE_NAME == "obsidian" && $1 =~ ^(https?://) ]]; then
        unset XDG_DATA_HOME
        unset XDG_CONFIG_HOME
fi

exec /usr/bin/xdg-open "$@"
  • save the script
  • make it executable: chmod +x ~/bin/xdg-open

Now obsidian should run correct browser.

DISCLAIMER: There may be some unexpected downsides coming from this solution. It wasn’t tested very deeply. USE AT YOUR OWN RISK. Maybe there is better solution but this piece of “duct tape” solved my case :wink:

  1. If xdg-open run from the console opens wrong browser, use the solution suggested by others (to fix your system level configuration):
xdg-mime default google-chrome.desktop x-scheme-handler/http
xdg-mime default google-chrome.desktop x-scheme-handler/https

Why this (1) works?

From my quick investigation:

  • strace shows that obsidian searches for xdg-open on PATH and invokes the first one found
  • xdg-open executed from console normally opens the right browser
  • xdg-open executed by obsidian opens wrong browser

After comparing the env output I’ve spotted that Snap crates it’s own XDG “environment”, where especially the two variables cause trouble (although there may be more…):

XDG_DATA_HOME=/home/youruser/snap/obsidian/24/.local/share
XDG_CONFIG_HOME=/home/youruser/snap/obsidian/24/.config

The XDG_CONFIG_HOME messes with configuration (which browser should open) and the XDG_DATA_HOME messes with browser (at least chrome does respect this variable - Chromium Docs - User Data Directory - and due to this it starts new process with empty profile).

So removing those two from environment before invoking real xdg-open falls back to your default config.

4 Likes

@osomdev Thanks for sharing your findings!

How can I do that when starting obsidian from the launcher icon (I am using Ubuntu 23.10) ? Will it not use a the Ubuntu default PATH in that case? And that PATH will not include ~/bin I guess. I observed that I have xdg-open installed in both /bin and /usr/bin. I tried to replace the /bin/xdg-open with the script you provided, but when I click a link in obsidian it just hangs (nothing happens, it does not even open the link in the wrong browser). (After reinstalling the original version of the xdg-open in /bin/xdg-open obsidian opens the link in the wrong browser again)

Any changes for this bug to be fixed without any witchcraft?

Hi again,

A comment on the findings posted by @osomdev. Maybe it helps someone.

I went into my obsidian snap installation directory
~/snap/obsidian/x2/.config and I found that it indeed has a mimeapps.list file which has firefox a the default application.

Naively, I attempted to change this to chrome, and It semi-worked. I got obsidian to open links in chrome, however, it always opening a new window (Perhaps because I am using several different chrome profiles). I would of course want it to open a new tab in the currently opened (or latest used) chrome window as is usually the case.

I can only assume that I encountered the empty profile mentioned in:

the XDG_DATA_HOME messes with browser (at least chrome does respect this variable - Chromium Docs - User Data Directory - and due to this it starts new process with empty profile).

After trying out osomdevs xdg-open script my problem went away, and everything works great!

@hakonhagland You should probably not replace any existing binaries. I assume that osomdevs script (which is a wrapper) works by ~/bin being earlier in the PATH than wherever your usual xdg-open binary is located, thereby executing the wrapper first, which in turn does: exec /usr/bin/xdg-open "$@"

I placed mine in ~/.local/bin/xdg-open and that worked fine

I have the same problem. This workaround from @osomdev worked for me as well, thanks!

It would be great to see this fixed in Obsidian.