djblue / portal

A clojure tool to navigate through your data.
https://djblue.github.io/portal/
MIT License
872 stars 81 forks source link

Ubuntu: get-chrome-bin returns `/usr/bin/snap` #203

Closed mrnhrd closed 8 months ago

mrnhrd commented 9 months ago

Hi there I'm running on Ubuntu LTS 20.04.6 and was trying to get portal to run, following the default instructions:

;; ~/.lein/profiles.clj
{:user {:plugins [[lein-pprint "1.1.1"]]
        :dependencies [[djblue/portal "0.49.1"]]}}
mrnhrd@ubuntu-20:~$ lein repl
nREPL server started on port 44625 on host 127.0.0.1 - nrepl://127.0.0.1:44625
REPL-y 0.4.3, nREPL 
Clojure 1.10.1
OpenJDK 64-Bit Server VM 1.8.0_372-b07 ;; happens on JVM 17 & clj 1.11 too, as well as on bb
*** Lein help omitted ***

user=> (require '[portal.api :as p])
nil
user=> (p/open)
{:session-id #uuid "185235a7-12d2-42ef-8e49-e2104e431bf4"}
["/usr/bin/snap" "--app=http://localhost:44755?185235a7-12d2-42ef-8e49-e2104e431bf4"]
error: unknown flag `app'

No window appears, but I can browse to the url in a browser. So chromium was not launched because of that malformed command line.
Through experimentation I was able to deduce that browser/get-chrome-bin (and fs/find-bin) returned "/usr/bin/snap" which is of course wrong. The culprit for all this appears to be Ubuntu, which installs chromium as a snap and snap apparently manages executables by creating symlinks. Observe the following truncated ls incantation in /snap/bin:

mrnhrd@ubuntu-20:/snap/bin$ ls -lh
total 0
lrwxrwxrwx 1 root root 13 Nov 26 22:10 chromium -> /usr/bin/snap*

And java.io then resolves this link.

I don't know that the reasonable solution is here, but ubuntu also has chromium under /usr/bin/chromium-browser (probably depends on chromium-browser having been installed via apt*), and by linking that as chromium somewhere else in my $PATH some path precedence magic then makes it work on my machine:

sudo ln -s /usr/bin/chromium-browser /usr/local/bin/chromium

Changing the executable name to chromium-browser at the bottom of get-chrome-bin also works, though I suppose neither of those approaches are the clean solution here.

* which btw does not appear to actually install a second chromium. After doing snap remove chromium, chromium-browser (which was installed via apt) then tells you to that it depends on the snap and to re-install it...

djblue commented 9 months ago

Hi @mrnhrd, thanks for reporting this. I think adding chromium-browser before chromium in the browser vector should solve this issue. Did you want to submit a PR?