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

Flatpak registration doesn't alway work #160

Closed
CHJ85 opened this issue Sep 6, 2023 · 45 comments
Closed

Flatpak registration doesn't alway work #160

CHJ85 opened this issue Sep 6, 2023 · 45 comments

Comments

@CHJ85
Copy link

CHJ85 commented Sep 6, 2023

Hi there. vdhcoapp is not recognized by Firefox build 117.0, on Manjaro Linux.
I installed it first through the official website. When that didn't work, I used the AUR build.
Both are essentially the same package with the same files, same installation location and so on.
The installation directory is the same as always "/opt/net.downloadhelper.coapp".
At first I thought it was a file permission issue, so I changed the owner of the directory and files from root to my local user. This did not do the trick either. Sometimes it does when permissions are messed up for whatever reason.

@paulrouget
Copy link
Member

Can you point me to the AUR build? I'll double check that it's correct.

If you run the binary that way, what happens:

/opt/net.downloadhelper.coapp/net.downloadhelper.coapp-linux-XX

?

In theory it should just hang and do nothing. Can you confirm?

Then, try this:

/opt/net.downloadhelper.coapp/net.downloadhelper.coapp-linux-XX install --user

And check if the extension works.

Thank you.

@CHJ85
Copy link
Author

CHJ85 commented Sep 7, 2023

The first command just hung like you said, as all it does is open the program.
The 2nd command says: VdhCoApp: VdhCoApp is ready to be used
The program itself seem to be working just fine.

Here's the AUR package:
https://aur.archlinux.org/packages/vdhcoapp

It's the regular Firefox install from the Arch repo:
https://archlinux.org/packages/extra/x86_64/firefox/

@paulrouget
Copy link
Member

paulrouget commented Sep 7, 2023

Does it create a file .mozilla/native-messaging-hosts/net.downloadhelper.coapp.json ?
And you open that file, does the path correlate with the path of the coapp binary?

@CHJ85
Copy link
Author

CHJ85 commented Sep 7, 2023

Yes and yes.
Here's the content of the file:```

{
"name": "net.downloadhelper.coapp",
"description": "Video DownloadHelper companion app",
"path": "/opt/net.downloadhelper.coapp/bin/net.downloadhelper.coapp-linux-64",
"type": "stdio",
"allowed_extensions": [
"weh-native-test@downloadhelper.net",
"{b9db16a4-6edc-47ec-a1f4-b86292ed211d}"
]
}


However, I'm still getting this screen whenever I try to download a video:
https://i.imgur.com/49j0sGo.png

@paulrouget
Copy link
Member

If you go here:

https://github.com/aclap-dev/vdhcoapp/blob/master/assets/instruction1.png

Does it say the companion app is not installed?

@CHJ85
Copy link
Author

CHJ85 commented Sep 7, 2023

Idk what you want me to look for there. It's an image screenshot that says "No media to process in the current tab".

@paulrouget
Copy link
Member

  • in Firefox, click on the add-on button
  • click on the gear button (as shown in the image)
  • this will open a new page
  • in that new page, does it say the companion app is installed?

@paulrouget
Copy link
Member

Also, can you give it a try with a Firefox official build?

Download https://download.mozilla.org/?product=firefox-latest-ssl&os=linux64&lang=en-US untar, and run. See if this changes anything.

Thanks for helping out.

@CHJ85
Copy link
Author

CHJ85 commented Sep 8, 2023

Oh, sorry about that. 😀
It still says "Companion App not installed"

@mokshasoul
Copy link

mokshasoul commented Sep 12, 2023

Hey I had a very similar issue on Arch*

The native messaging JSON contained the wrong add-on ID that was allowed, thus actually even if installed it wasn't allowing Firefox to communicate with the native host add-in

I fixed it by adding the addons actual ID (so replacing "{b9db16a4-6edc-47ec-a1f4-b86292ed211d}" with whatver ID you get if you inspect the addon in FF)

Took me months to solve ;D

@paulrouget
Copy link
Member

@mokshasoul how is your ID not {b9db16a4-6edc-47ec-a1f4-b86292ed211d} ? Where are you getting your addon from? Are you sure you're getting the official addon?

@paulrouget
Copy link
Member

@CHJ85 where are you getting the download helper extension from?

@paulrouget
Copy link
Member

@mokshasoul what's the ID of the extension?

@mokshasoul
Copy link

I'm going to have a look in the vening its on my desktop, maybe I'm missremembering something but it was def. an issue with the native-messaging file

@CHJ85
Copy link
Author

CHJ85 commented Sep 13, 2023

I downloaded the addon from the mozilla addon website.

@CHJ85
Copy link
Author

CHJ85 commented Sep 13, 2023

I solved it. Not sure what the problem was. But now it says "Companion App installed" after I uninstalled the current one and installed the vdhcoapp-bin version from the AUR instead of the standard one. Guess there's a difference between the 2 packages..
Thanks for all your help.

@paulrouget
Copy link
Member

@mokshasoul thanks - just let me know what the json file look like on your system.

@paulrouget
Copy link
Member

paulrouget commented Sep 13, 2023

I solved it. Not sure what the problem was. But now it says "Companion App installed" after I uninstalled the current one and installed the vdhcoapp-bin version from the AUR instead of the standard one. Guess there's a difference between the 2 packages.. Thanks for all your help.

Understood. I think the issue was the binary location on aur-based packages.

@mokshasoul
Copy link

mokshasoul commented Sep 14, 2023

This is what I ended up with btw: {0274c307-d9af-4970-96d5-964d6bf5d123}

@boydthomson
Copy link

I'm having the same issue with the FireFox snap 117.0.1 on Ubuntu 22.04.3

I did /opt/net.downloadhelper.coapp/bin/net.downloadhelper.coapp-linux-64 install --user
VdhCoApp: VdhCoApp is ready to be used

but FF still says the companion app isn't installed. I tried on Chromium also with similar results.

@CHJ85
Copy link
Author

CHJ85 commented Sep 19, 2023

@boydthomson In Ubuntu, Snap packages are stored in a different location than traditional APT-based packages. Snap packages are typically stored in the /snap directory. Each Snap package will have its own subdirectory under /snap where it is mounted.

For Firefox installed via Snap, you should find the relevant files under /snap/firefox/
So, in order for vdhcoapp to work, I believe you have to place net.downloadhelper.coapp to the snap directory.
Mind you, I do not use snaps, so I could be wrong on the exact location.

@paulrouget
Copy link
Member

@boydthomson Hi! I think this has been fixed by the Firefox team recently. It should work "out of the box". Do you mind replying here: #168 ? I'd like to investigate.

@paulrouget
Copy link
Member

@mokshasoul Hey, do you mind telling me where you got your addon from? This ID is unknown to us. I think you might have installed an addon from the wrong place (might be unsafe).

@kkovaletp
Copy link

kkovaletp commented Oct 21, 2023

I have the same issue on Fedora KDE 38 with Firefox 118.0.2 and Chrome 118.0.5993.88, as a Flatpak, addon 8.0.0.6, vdhcoapp 2.0.4 from the https://www.downloadhelper.net/install-coapp-v2.

I did next steps:

  • unpacked it to /usr/local/vdhcoapp as root
  • executed the vdhcoapp install as root
Installing…
Writing /usr/lib/mozilla/native-messaging-hosts//net.downloadhelper.coapp.json
Writing /etc/opt/chrome/native-messaging-hosts//net.downloadhelper.coapp.json
Writing /etc/chromium/native-messaging-hosts//net.downloadhelper.coapp.json
Writing /etc/opt/edge/native-messaging-hosts//net.downloadhelper.coapp.json
VdhCoApp : VdhCoApp is ready to be used
  • executed the vdhcoapp install as normal user
Installing…
Flatpak is installed. Making the coapp available from browser sandboxes:
Linked coapp within org.mozilla.firefox.
Linked coapp within com.brave.Browser.
Linked coapp within com.google.Chrome.
Linked coapp within com.google.ChromeDev.
Linked coapp within org.chromium.Chromium.
Linked coapp within com.github.Eloston.UngoogledChromium.
Linked coapp within com.microsoft.Edge.
Linked coapp within com.microsoft.EdgeDev.
Writing /home/<user>/.mozilla/native-messaging-hosts/net.downloadhelper.coapp.json
Writing /home/<user>/.var/app/org.mozilla.firefox/.mozilla/native-messaging-hosts/net.downloadhelper.coapp.json
Writing /home/<user>/.var/app/com.google.Chrome/config/google-chrome/NativeMessagingHosts/net.downloadhelper.coapp.json
VdhCoApp : VdhCoApp is ready to be used
  • executed vdhcoapp --info as normal user
{
"id": "net.downloadhelper.coapp",
"name": "VdhCoApp",
"version": "2.0.4",
"binary": "/usr/local/vdhcoapp/vdhcoapp",
"displayName": "VdhCoApp",
"description": "Video DownloadHelper companion app",
"target": {
"os": "linux",
"arch": "x86_64",
"node": "18"
},
"home": "/home/kkoval",
"converterBinary": "/usr/local/vdhcoapp/ffmpeg",
"converterBase": "ffmpeg",
"converterBaseVersion": "6.0"
}
  • made sure the addon ID in FF is the same as in the JSON in all mentioned file locations
  • checked the Firefox permissions in Flatseal and tried to give more

Nothing has helped. Please let me know how to make it work.

UPD: this hint helped me: #137 (comment)
however, I assume that it is temporary solution, which will work until the next update of the Firefox flatpak, so I still want to find a more straight-forward and permanent solution.
While searching for some workarounds, I saw a proposal to create a flatpak extension with the coapp inside. To me it looks like a good idea, as it follows the flatpak's way to sandbox and extend apps instead of breaking the sandbox by additional communication channel to the host level.

@paulrouget
Copy link
Member

@kkovaletp hmm, the fact you have to use the linked workaround is surprising to me. This is not supposed to be necessary anymore in Firefox. You're not the first one to run into that issue, and I'd like to get to the bottom of it. Would be great if you could help out.

  • where does the flatpak come from?
  • Did you get a prompt from Firefox saying the an extension is trying to use the Native Messaging?
  • if not, in the privacy settings of Firefox, do you see any options about Native Messaging being allowed?

@paulrouget paulrouget changed the title vdhcoapp and Firefox 117.0 on Manjaro Flatpak registration doesn't alway work Oct 23, 2023
@kkovaletp
Copy link

@paulrouget it is a surprise for me that there is a requirement \ dependency to the FF privacy settings: I didn't see that in the installation instructions. I think that providing the complete list of all the requirements as a prerequisite step of the installation guide would really help in many cases.

  • the flatpak is from the Flathub
  • no, I didn't get any notifications, just the message that the co-app isn't installed and an exception occurred during the verification of the connection
  • I do have some restrictions in the FF privacy and security settings, but I don't see anything about the Native Messaging. Could you please double-check and provide me the exact setting name, so that I can let you know the value of it?

@paulrouget
Copy link
Member

paulrouget commented Oct 23, 2023

@kkovaletp

it is a surprise for me that there is a requirement \ dependency to the FF privacy settings

There is not. Firefox has that option, but it's off by default.

an exception occurred during the verification of the connection

What do you mean?


I doubled checked here, and it seems to work as expected. I'd like to understand how your setup differs from mine.

Can you confirm these 3 json have exactly the same content and are all pointing to /usr/local/vdhcoapp/vdhcoapp

  • /usr/lib/mozilla/native-messaging-hosts//net.downloadhelper.coapp.json
  • /home//.mozilla/native-messaging-hosts/net.downloadhelper.coapp.json
  • /home//.var/app/org.mozilla.firefox/.mozilla/native-messaging-hosts/net.downloadhelper.coapp.json

Also, can you check in Firefox menu > Help > About Firefox that it says "mozilla-flatpak - 1.0"?

@kkovaletp
Copy link

@paulrouget

An exception occurred during the verification of the connection

VDH settings > General > Companion App not installed > Checking companion app returned: An unexpected error occurred

3 json have exactly the same content and are all pointing to /usr/local/vdhcoapp/vdhcoapp

yes, used KDiff to make sure)

Firefox menu > Help > About Firefox that it says "mozilla-flatpak - 1.0"

yes

@paulrouget
Copy link
Member

What does this file says:

cat ~/.local/share/flatpak/overrides/org.mozilla.firefox

@kkovaletp
Copy link

kkovaletp commented Oct 23, 2023

@paulrouget

cat ~/.local/share/flatpak/overrides/org.mozilla.firefox

[Context]
devices=dri;
filesystems=/home/<user>/.mozilla;/usr/local/vdhcoapp:ro;

@paulrouget
Copy link
Member

Everything seems correct. Thanks again for helping out!

Can you try 2 things for me:

  • in the Firefox settings, check the addon permissions. It should look like that:
Screenshot 2023-10-24 at 09 24 20
  • I'm wondering if there's not a vestige of another json registration file. Do you mind trying with a clean profile & clean pak dir:
# Quit Firefox (make sure no process is left hanging)
# and in that specific order:
mv ~/.mozilla ~/_mozilla_backup
mv ~/.var/app/org.mozilla.firefox ~/org_mozilla_firefox_backup
rm ~/.local/share/flatpak/overrides/org.mozilla.firefox
flatpak run org.mozilla.firefox
# Wait until Firefox is up and running
/usr/local/vdhcoapp/vdhcoapp install
# Install VDH from here: https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/
# Check if coapp is recognized
# Quit Firefox (make sure no process is left hanging)
# Restore the backup files:
rm -rf ~/.mozilla && mv ~/_mozilla_backup ~/.mozilla 
rm -rf ~/.var/app/org.mozilla.firefox && mv ~/org_mozilla_firefox_backup ~/.var/app/org.mozilla.firefox

@kkovaletp
Copy link

@paulrouget

  • the addon permissions

I have all the same

  • trying with a clean profile & clean pak dir

I did all as described and got the same result: co-app not found, unexpected error in the add-on settings.
BTW, you forgot to backup the overrides, I did it as well
BTW 2: when I press the setup co-app button (next to the find co-app one in the add-on settings), the v1 page opens with the 1.6.3 version. Why isn't it updated to point to the v2 page with the latest co-app version?

I tried to analyze what else could prevent the browser from communicating with the co-app on the host. I'm not sure how flatpak apps communicate with the host, but I have a firewall and SELinux enabled. Don't I need to add some configuration there?

@paulrouget
Copy link
Member

Why isn't it updated to point to the v2 page with the latest co-app version?

Because V2 is still in testing phase. It will open the V2 download page if you use the beta version of the addon: https://www.downloadhelper.net/firefox/betas

SELinux

Oh… that might be it.

Maybe this is relevant: https://discussion.fedoraproject.org/t/does-selinux-confine-flatpack-apps/73111/3

I don't have SELinux installed here. Hard to try to reproduce.

@kkovaletp
Copy link

kkovaletp commented Oct 24, 2023

@paulrouget

V2 is still in testing phase.

OK, I see. It must have been in beta for a long time already, as I remember that I've been using the 2.x version on my Mac for a while - it was installed and updated by the homebrew there.

Maybe this is relevant

I'm really far away from configuring SELinux manually)
Here is what I see for the FF from the ls -lZ /var/lib/flatpak/app/org.mozilla.firefox command:

lrwxrwxrwx. 1 root root system_u:object_r:var_lib_t:s0   13 окт 15 17:17 current -> x86_64/stable
drwxr-xr-x. 3 root root system_u:object_r:var_lib_t:s0 4096 окт 15 17:17 x86_64

and here is the output for the /usr/local/vdhcoapp

-rwxr-xr-x. 1 root root unconfined_u:object_r:usr_t:s0 48653608 окт 19 08:04 ffmpeg
-rwxr-xr-x. 1 root root unconfined_u:object_r:usr_t:s0 48539368 окт 19 08:04 ffprobe
-rw-r--r--. 1 root root unconfined_u:object_r:usr_t:s0    15220 окт 19 08:04 LICENSE.txt
-rw-r--r--. 1 root root unconfined_u:object_r:usr_t:s0     4461 окт 19 08:04 README.md
-rwxr-xr-x. 1 root root unconfined_u:object_r:usr_t:s0 48349265 окт 19 08:04 vdhcoapp
-rwxr-xr-x. 1 root root unconfined_u:object_r:usr_t:s0    25778 окт 19 08:04 xdg-open

Maybe you could advise on how to modify it if needed?

Hard to try to reproduce.

setting up a VirtualBox VM isn't an option for you?

@paulrouget
Copy link
Member

I installed Fedora, and I cannot reproduce the issue.

I'm running out of ideas.

@kkovaletp did this use to work with the older coapp?

@paulrouget
Copy link
Member

@kkovaletp also, to make sure it's indeed a sandboxing issue (SELinux or Flatpak), can you try to download a non-flatpak version of Firefox (https://www.mozilla.org/en-US/firefox/linux/) and see if it works?

@kkovaletp
Copy link

@paulrouget, sorry for the delay, I was busy with other things...

I installed Fedora, and I cannot reproduce the issue.

Did you install the Fedora 38 KDE or the regular one with Gnome? I use the KDE build

did this use to work with the older coapp?

no, it is not. the behavior is completely the same as for 2.x version:
no co-app was found in the case of system installation and unexpected error in the case of user installation.
BTW, is there a way to see the text and stacktrace of the unexpected error, reported on the add-on settings page? it might help to debug the issue...

can you try to download a non-flatpak version of Firefox

it works in non-flatpak version with enabled SELinux right after installation of the add-on, as co-app is installed system-wide and user-wide, but for some reason, the dnf-installed FF don't use the same profile, as the flatpak one, so it was started clean and I had to install the add-on manually.
also, I found a command to temporary disable SELinux for testing: setenforce 0. there is no difference after execution of the command and restart the flatpak FF, so the root cause is not in SELinux, but somewhere in flatpak

@paulrouget
Copy link
Member

paulrouget commented Oct 26, 2023

Did you install the Fedora 38 KDE or the regular one with Gnome? I use the KDE build

Gnome. It's possible that there is a KDE-specific thing going on here.

BTW, is there a way to see the text and stacktrace of the unexpected error, reported on the add-on settings page? it might help to debug the issue...

Sadly no. The process is spawned by Firefox itself. So it's not something we can easily debug. You can strace the firefox process see when the coapp is launched. But that's a little technical.

From what you're describing, it feels like the Firefox short-circuit to traverse the flatpak sandbox doesn't work on your machine. I think for these weird case, best is to install the coapp within the Firefox sandbox. It's stupid but I don't see a better way of doing it.

@kkovaletp
Copy link

@paulrouget, I finally got it working!
and as usual, the fix was so easy and on the surface, but I dug too deep in the wrong direction)

when I wrote the previous comment and asked about the way to debug it, I started googling how to debug an add-on for FF and how to debug the FF itself on the flatpak level. and I found the command:
flatpak run --log-session-bus --log-system-bus com.application.id &> logfile.txt

once I started the FF this way, I pressed a button to find the co-app to trigger the error again to be logged. then I analyzed the log and the 1st string there was:
F: Do not share "/usr/local/vdhcoapp" with the sandbox: Path "/usr" reserved for Flatpak
there are other errors, but they are obviously caused by this one.
so, I've uninstalled the co-app from the /usr/local/vdhcoapp, moved it to the /opt folder, and installed it from there.

and it just works!

now I remember that there is a good practice on Linux to put all unpackable software in the /opt folder, as it is created exactly for such content, but I trusted the instructions on the download page and ignored this question until I saw the error...

@paulrouget
Copy link
Member

@kkovaletp oh wow … that's amazing detective work. Thank you so much! I will update the documentation right away :)

@mister-bum
Copy link

@paulrouget, I finally got it working! and as usual, the fix was so easy and on the surface, but I dug too deep in the wrong direction)

when I wrote the previous comment and asked about the way to debug it, I started googling how to debug an add-on for FF and how to debug the FF itself on the flatpak level. and I found the command: flatpak run --log-session-bus --log-system-bus com.application.id &> logfile.txt

once I started the FF this way, I pressed a button to find the co-app to trigger the error again to be logged. then I analyzed the log and the 1st string there was: F: Do not share "/usr/local/vdhcoapp" with the sandbox: Path "/usr" reserved for Flatpak there are other errors, but they are obviously caused by this one. so, I've uninstalled the co-app from the /usr/local/vdhcoapp, moved it to the /opt folder, and installed it from there.

and it just works!

now I remember that there is a good practice on Linux to put all unpackable software in the /opt folder, as it is created exactly for such content, but I trusted the instructions on the download page and ignored this question until I saw the error...

Excuse me if I hijack this already closed thread, but I am neither very competent with github nor with Linux. I have installed the co-app using the /usr folder and it works with the vivaldi browser which is installed from the main repository. However, the /opt folder would have been my first choice, but the instructions clearly state not to install the co-app as sudo. And afaik, it is not even possible to copy files to /opt without sudo. Is it possible to run the install in the /opt folder without using sudo rights?
I could of course simply try this, but I am reluctant to fiddle with a working configuration...

@paulrouget
Copy link
Member

@mister-bum

Let me try to clarify the installation process on Linux:

If you use the .deb, just install it with dpkg -i the_deb_file.deb or double click on the file. This can be done as root, no problem.

If you use the .tar.bz2, extract it where ever you want, as root or not, doesn't matter. Just do not extract it in /usr/ if you're using a snap/flatpak based browser.

If you use the .tar.bz2, then you need to run as user (not sudo) the vdhcoapp install command (not necessary if you used the .deb).

Please not we have an issue at the moment with the CoApp and Ubuntu: aclap-dev/video-downloadhelper#12

Hope this helps.

@kkovaletp
Copy link

kkovaletp commented Jan 26, 2024

the instructions clearly state not to install the co-app as sudo

(I assume that) The idea behind this recommendation is to limit the co-app installation to the current user while installing it using sudo will apply the configuration system-wide, but won't affect other regular users (which is confusing, if you don't understand how Linux user management works). Anyway, chances that you'll need the co-app running on the system level are pretty low, so for most cases, you don't need the sudo installation.

Is it possible to run the install in the /opt folder without using sudo rights?

Yes, but you need to do some preparation:

  • find out your username and groupname by running the id command. your username will be in () after uid= and groupname - after gid=. Then you'll see all other groups, you're a member of.
  • create a folder for the co-app: sudo mkdir /opt/vdhcoapp
  • change the ownership of the folder to your user by: sudo chown <username>:<groupname> /opt/vdhcoapp
  • double-check that the folder has drwxr-xr-x permissions and is owned by the correct user: ls -lah /opt. If permissions are not correct, run chmod 755 /opt/vdhcoapp - it shouldn't require sudo, as you're an owner now.
  • unpack the downloaded co-app to the /opt/vdhcoapp and install it under your user, as described in the guide

@mister-bum
Copy link

Wow, many thanks to both of you for your very prompt replies!! Both of them are helpful to me.

The .deb approach is what I used successfully for the last months. But sometimes software is provided only as a .tar.bz2 and just to get used to handle these files, I decided to install the co-app from the .tar archive this time. Kind of a modest personal linux workout... ;-)

Thanks for pointing out the importance of the ownership - I have the feeling that this was the missing piece for me to understand how to use the /opt folder without using the install command as root.

Have a nice weekend both of you !!

@philmcrakin
Copy link

If you're using Libre Wolf it works if you move the native-messaging-hosts directory to /usr/lib/librewolf/

It should match this:
/usr/lib/librewolf/native-messaging-hosts/net.downloadhelper.coapp.json

Sorry if this is in the wrong place or already mentioned elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants