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

Thunderbird 102 Flatpak not working #50

Open
JonnyCodewalker opened this issue Nov 10, 2022 · 32 comments
Open

Thunderbird 102 Flatpak not working #50

JonnyCodewalker opened this issue Nov 10, 2022 · 32 comments

Comments

@JonnyCodewalker
Copy link

JonnyCodewalker commented Nov 10, 2022

This addon does not work in the Thunderbird Flatpak.

Thunderbird: 102.4.2
Flatpak: 1.14.0
Gnome: 43.0

Output:

*** 2022-11-10T13:16:27.437Z LOG  edscalendar.edscalendar : Loaded prefs
JavaScript error: , line 0: uncaught exception: Object
JavaScript error: undefined, line 0: Error: An unexpected error occurred
*** 2022-11-10T13:16:31.993Z LOG  edscalendar.edscalendar : Shutting down Eds Calendar
*** 2022-11-10T13:16:35.420Z LOG  edscalendar.edscalendar : Loaded prefs
JavaScript error: , line 0: uncaught exception: Object
JavaScript error: undefined, line 0: Error: An unexpected error occurred 

error.log

@balbusm
Copy link
Owner

balbusm commented Nov 11, 2022

I need more details:

  1. What version of the addon are you using?
  2. How do you integrate with your calendars (protocol, addon used to sync your calendar)?

@JonnyCodewalker
Copy link
Author

JonnyCodewalker commented Nov 11, 2022 via email

@balbusm
Copy link
Owner

balbusm commented Nov 13, 2022

Looks that you don't have evolution data server installed.
You didn't specify distro, but basically you need this (example for Debian):
https://packages.debian.org/buster/evolution-data-server

@JonnyCodewalker
Copy link
Author

JonnyCodewalker commented Nov 13, 2022 via email

@balbusm
Copy link
Owner

balbusm commented Nov 13, 2022

Try version 1.0.1.
It doesn't fix the issue but you should get more verbose error message.
My assumption is that addon fails to find library libecal-2.0.so (it's part of the evolution-data-server).
You can try to find location of above library and check if it's accessible (ldconfig -p might be helpful).
Description where Linux looks for libraries:
https://unix.stackexchange.com/questions/22926/where-do-executables-look-for-shared-objects-at-runtime

@JonnyCodewalker
Copy link
Author

JonnyCodewalker commented Nov 13, 2022 via email

@StarkZarn
Copy link

This appears to still be an issue in May of 2023. I'm on 102 via flatpak and the extension still doesn't talk to EDS, even with additional permissions granted via flatseal.

@balbusm
Copy link
Owner

balbusm commented May 4, 2023

I guess it's related to the problem described here and here
Addon looks for evolution data server libraries in /usr/lib but they are mounted at /var/run/host/usr/lib

Try this:

  • Make sure you have installed evolution-data-sever on your machine
  • Check location of required libs:
find /usr -name libecal-2.0.so*
find /usr -name libglib-2.0.so*
find /usr -name libical-glib.so*
  • Make it accessible to Flatpak (assuming libs are in /usr/lib)
sudo flatpak override <package identifier> --filesystem=/usr/lib
  • Provide logs if there are still issues

@marouamghar
Copy link

@balbusm I did try that, it doesn't work:
Not sharing "/usr/lib64" with sandbox: Path "/usr" is reserved by Flatpak
I even tried copying the libs directly in the Thunderbird lib folder, but to no avail.

@JonnyCodewalker
Copy link
Author

JonnyCodewalker commented Jul 1, 2023 via email

@czhang03
Copy link

czhang03 commented Jan 31, 2024

I got the following error, when given the host-os:ro permission to Thunderbird (which should give it the /var dir):

$ flatpak run org.mozilla.Thunderbird 
[ImapModuleLoader] Using nsImapService.cpp
*** 2024-01-31T19:00:20.444Z LOG  edscalendar.edscalendar : Loaded prefs
*** 2024-01-31T19:00:20.447Z LOG  edscalendar.libLoader : Opened libglib-2.0.so.0
*** 2024-01-31T19:00:20.448Z LOG  edscalendar.libLoader : Opened libgio-2.0.so.0
*** 2024-01-31T19:00:20.448Z LOG  edscalendar.libLoader : Opened libgobject-2.0.so.0
*** 2024-01-31T19:00:20.454Z ERROR  edscalendar.edscalendar : Cannot load edsCalendarClient
  LoadingLibException: Library libecal-2.0.so or libecal-1.2 not available. EdsCalendar requires EDS >= 0.8
  Stack:
    LoadingLibException@resource://edscalendar/legacy/modules/utils/exceptions.jsm:33:5
loadOldEdsLib@resource://edscalendar/legacy/modules/bindings/edslib.jsm:72:13
loadEdsLib@resource://edscalendar/legacy/modules/bindings/edslib.jsm:48:19
init@resource://edscalendar/legacy/modules/bindings/libedataserver.jsm:48:27
CalEdsProvider@resource://edscalendar/legacy/modules/calEdsProvider.jsm:73:22
@resource://edscalendar/legacy/modules/calEdsProvider.jsm:980:24
@resource://edscalendar/legacy/modules/edsCalendarClient.jsm:34:40
createEdsCalendarClient@jar:file:///var/home/cheng/.thunderbird/wqh2dpdh.default-release-1/extensions/%7Be6696d02-466a-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js:88:49
onStartup@jar:file:///var/home/cheng/.thunderbird/wqh2dpdh.default-release-1/extensions/%7Be6696d02-466a-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js:50:35


JavaScript error: jar:file:///var/home/cheng/.thunderbird/wqh2dpdh.default-release-1/extensions/%7Be6696d02-466a-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js, line 95: Error: Cannot load edsCalendarClient
JavaScript error: undefined, line 0: Error: An unexpected error occurred

And I can find libecal-2.0.so.2 (Not libecal-2.0.so) on host:

$ sudo find /usr -name libecal-2.0.so*
/usr/lib64/libecal-2.0.so.2
/usr/lib64/libecal-2.0.so.2.0.0

I am on a fedora silverblue based image, specifically silverblue-main-laptop-userns-hardened from secureblue

@czhang03
Copy link

czhang03 commented Jan 31, 2024

I think flatpak probably do not expose libraries like libcal for searching. However, instead of only searching for libecal-1.2.so, we can search for /run/host/usr/lib64/libecal-2.0.so.2 as a fallback.

This might require a minor extension to the loadLib function or tryLoadLib function, but it doesn't seem to be too complicated.

Specifically, I think the following code would work (with host-os access permission):

function tryLoadLib(libName) {
  const libPaths = [
     "",  // do not specify path
     "/run/host/usr/lib64/"  // flatpak lib path
   ]

  // try to find lib in all the lib paths
  for (libPath of libPaths) {
    try {
        let lib = ctypes.open(libPath + libName);
        LOG("Opened " + libName);
        return lib;
    } catch (err) {
      return null;
    }
  }
}

I am not sure whether we need to include more path in the search, specifically like /usr/lib64/ or /run/host/usr/lib/, but so far, it doesn't seem necessary.


Finally, I don't think using ctype in an extension is ideal, as it is very deprecated. But I also don't see a better way to achieve this functionality, unless thunderbird wants to implement it themselves.

@vendillah
Copy link

@czhang03, can you create a fork so that we can test it? I assume we can try it by downloading a zip from your repository and install it manually.

I think I could try to implement your changes, as you documented them quite well with references, but I'm afraid I can easily start wasting my time when things don't work. I'd assume there may be something else I'd have forgotten, as I have zero knowledge about flatpak's internal working or MailExtensions, and could easily waste time :/

To be clear, does Thunderbird need additional permissions for this to work? If yes, is it possible to provide the flatpak override commands? So far, I haven't changed its permissions at all. If this is expected, it would be nice to have this shown in the README. Actually more documentation on the non-developer setup and the requirements such as a running evolution-data-server and commands to test if its running properly would be nice.

@czhang03
Copy link

czhang03 commented Feb 5, 2024

Thanks @vendillah , I don't have much time at the moment, but I am happy to test this ASAP. Probably that will be somewhere around the end of Feburary.

@czhang03
Copy link

czhang03 commented Feb 5, 2024

I am just writing down some security implications to this change.

Give a flatpak app host-os permission is in general no ideal, there is also no way to (and probably also no reason to) limit a flatpak application to only access a particular library in /usr/.

Thus, the fix proposed above can only be a temporary hack. I think the proper way is still to ask thunderbird package libecal in their flatpak application, or talk to a separate flatpak libecal plugin, as per flatpak/flatpak#5575 (comment):

As I said on flatpak/flatpak#5617, taking arbitrary code from the host OS distribution and injecting it into processes running inside the Flatpak sandbox is not something Flatpak aims to support,

This integration with libecal and/or evolution-data-server in flatpak has been discussed here, and is probably something that can be considered by the "Better Gnome Desktop Integration" proposal.

@vendillah
Copy link

Hm, so at the risk of sounding not so serious: I somehow made it work in the last days (since my previous post), without noticing.

I recently upgraded from Zorin OS 16 to Zorin OS 17, hence I've been "fixing" my OS (workflow). There was a gnome extension that integrated the todo list in the shell. I figured I hadn't installed another package required for evolution data server? I'm not sure. I think I ran the following command as described in Task Widget's installation guide.

sudo apt install gir1.2-edataserver-1.2 gir1.2-ecal-2.0 gir1.2-ical-3.0

I had restarted my computer to check if it worked. It didn't. I opened Thunderbird and didn't see anything change. Maybe the change took effect after another (shell/system) restart? I don't know what else it could have been. After that anyway, I no longer bothered really, until I noticed some dots in my calendar. Of course, this is only relevant to those who run a debian based system.

I am not that technical. I'm just wondering if by chance it contains the library that this extension is searching for. Also @czhang03, is there some persmission I should check? Honestly, I generally don't know the security implications of changing flatpak permissions, so I try to not touch it at all, but I may have changed a setting a long time ago that makes this possible. Feel free to ask questions or ignore this completely.

@samgarmany
Copy link

Hm, so at the risk of sounding not so serious: I somehow made it work in the last days (since my previous post), without noticing.

I recently upgraded from Zorin OS 16 to Zorin OS 17, hence I've been "fixing" my OS (workflow). There was a gnome extension that integrated the todo list in the shell. I figured I hadn't installed another package required for evolution data server? I'm not sure. I think I ran the following command as described in Task Widget's installation guide.

sudo apt install gir1.2-edataserver-1.2 gir1.2-ecal-2.0 gir1.2-ical-3.0

I had restarted my computer to check if it worked. It didn't. I opened Thunderbird and didn't see anything change. Maybe the change took effect after another (shell/system) restart? I don't know what else it could have been. After that anyway, I no longer bothered really, until I noticed some dots in my calendar. Of course, this is only relevant to those who run a debian based system.

I am not that technical. I'm just wondering if by chance it contains the library that this extension is searching for. Also @czhang03, is there some persmission I should check? Honestly, I generally don't know the security implications of changing flatpak permissions, so I try to not touch it at all, but I may have changed a setting a long time ago that makes this possible. Feel free to ask questions or ignore this completely.

I've been having the same issue on Fedora Silverblue and I know I have the evolution data server installed. Any chance you could check your flatseal permssions for thunderbird and see if they're different from the defaults? I would really like to make it work.

@vendillah
Copy link

By habit, I kept looking at the agenda of Thunderbird, only occasionally Gnome's Calendar and Shell's calendar. It appears that the syncing is no longer working, and it's hard to say when it stopped. I only noticed recently when I had removed some event, and they were still present in Gnome's Calendar. Reversely, google meets had been added in Thunderbird that didn't show up anymore. Perhaps the moment right after it suddenly synced? I accepted a meeting invite on 16 February, which is 10 days after I reported to have it fixed here. The meeting is visible in Gnome's Calendar.

I checked Flatseal, and I didn't see any changed parameters. (None of them has a blue warning triangle symbol.) I wish I could simply export the settings, but I can take screenshots if you desire to be sure.

In meanwhile, I enabled and disabled the extension in Thunderbird without success. I haven't yet tried installing and uninstalling the data-server, simply because I definitely wouldn't want to do that every time to sync my agenda. It's just so strange that it worked suddenly and then it suddenly doesn't anymore -_-

I had restarted my computer to check if it worked. It didn't. I opened Thunderbird and didn't see anything change. Maybe the change took effect after another (shell/system) restart?

I'm curious myself what changed that it stopped again. Did Thunderbird update? System packages? The extension? I will give an update if I discover how to get it working again.

@GalacticSun
Copy link

GalacticSun commented May 4, 2024

I would also like to get this working, if possible. I'm using Betterbird (Flatpak), not Thunderbird, but I wouldn't think that would make much of a difference. I tried making a symlink ln -s /usr/lib/x86_64-linux-gnu/libecal-2.0.so.1 /usr/lib/x86_64-linux-gnu/libecal-2.0.so since it seems be looking for libecal-2.0.so, and then added permission to /usr/lib/x86_64-linux-gnu/libecal-2.0.so in Flatseal, but that didn't work. I used the debug instructions from https://github.com/balbusm/xul-ext-eds-calendar#having-issues.

I'm getting the same error message that @czhang03 posted (#50 (comment)). I do have libecal-2.0.so installed and everything works fine with EDS Calendar in the non-Flatpak version of Betterbird. I'm using Linux Mint 21.3 Cinnamon.

Anyone have any ideas on how to make this work, or has anyone made any progress on resolving this, by chance?

@czhang03
Copy link

czhang03 commented May 4, 2024

@GalacticSun flatpak app uses a different usr dir than the system usr, even if you grant the host-os permission. See my previous comment: #50 (comment)

If you want to make this work, you can try the patch I suggested: #50 (comment) , and build it yourself to see if it works.

I no longer need this feature, nor do I want to maintain it, but I am happy to debug it with you.

@GalacticSun
Copy link

@czhang03 Thanks. I'd rather not have to build it myself, to be honest - not really sure how to do that. Is it hard to do? Would any further Flatpak updates then override my build? Also, are you sure your patch works okay?

What about manually moving libecal-2.0.so to the Flatpak /usr/ directory and then giving it permission in Flatseal to that directory?

@czhang03
Copy link

czhang03 commented May 5, 2024

I have no idea whether my patch works, since I have never tried it. As I have mentioned, I no longer have a usecase for this app.

Now that I think about it, you can grant host-os permission to thunderbird, then try to add /run/host/usr/lib64/ (your host usr) into the $PATH in the sandbox. I also don't think your symlink is necessary.

To do that, you will need to either hard-code the PATH in flatseal (flatseal doesn't support PATH=/run/host/usr/lib64/:$PATH"); or you will need to create a thunderbird.sh, which would modify path, and then run thunderbird:

#!/bin/bash

PATH=/run/host/usr/lib64/:$PATH && thunderbird

and launch it via flatpak run --command=thunderbird.sh org.mozilla.Thunderbird

@GalacticSun
Copy link

GalacticSun commented May 5, 2024

@czhang03 When you say adding my usr path, do you mean my path to libecal-2.0.so.1, which is /usr/lib/x86_64-linux-gnu/ on my regular os? (I don't have a /run/host/usr/lib64/, I'm guessing that is on your machine?)

I'd prefer to do it via Flatseal if possible, so I tried adding this to the "Environment" section in Flatseal:
PATH=/usr/lib/x86_64-linux-gnu/
But then Betterbird wouldn't launch at all. Maybe I got the syntax wrong or put it in the wrong place? When you say 'hard code' it in Flatseal, where do you mean to put it?

Also, would the flatpak override command be useful for this? Will it accept PATH, I wonder? https://unix.stackexchange.com/questions/559129/how-do-i-permanently-set-an-environment-variable-for-a-specific-flatpak-applicat

@czhang03
Copy link

czhang03 commented May 5, 2024

@GalacticSun I don't think flatpak override will help, this is a known limitation of flatpak (flatpak/flatpak#1415), and I don't think they are planning to fix it. I think you should try PATH=/run/host/lib/x86_64-linux-gnu/:/app/bin:/usr/bin in flatseal, see if this works.

@GalacticSun
Copy link

GalacticSun commented May 5, 2024

@czhang03 Thanks. Okay, I tried the following, none of which worked, unfortunately:

  • Changed the "Environment" section in Flatseal for Betterbird to be PATH=/run/host/lib/x86_64-linux-gnu/:/app/bin:/usr/bin (not sure what this path points to, I don't have this path on my system)

  • Changed the "Environment" section in Flatseal for Betterbird to be PATH=/usr/lib/x86_64-linux-gnu/:/app/bin:/usr/bin (this path exists and is where libecal is located).

  • I also tried re-adding that symlink again and tried launching Betterbird, but it didn't seem to help. sudo ln -s /usr/lib/x86_64-linux-gnu/libecal-2.0.so.1 /usr/lib/x86_64-linux-gnu/libecal-2.0.so (also made one that pointed to /usr/lib/x86_64-linux-gnu/libecal-2.0.so.1.0.0, which also didn't work)

find /usr -name libecal-2.0.so* returns the following:

/usr/lib/x86_64-linux-gnu/libecal-2.0.so.1.0.0
/usr/lib/x86_64-linux-gnu/libecal-2.0.so  (the symlink I created)
/usr/lib/x86_64-linux-gnu/libecal-2.0.so.1

Still getting the following error each time I try to run Betterbird:

LoadingLibException: Library libecal-2.0.so or libecal-1.2 not available. EdsCalendar requires EDS >= 0.8

Full error message:

Gtk-Message: 15:49:13.981: Failed to load module "xapp-gtk3-module"
console.warn: services.settings: Ignoring preference override of remote settings server
console.warn: services.settings: Allow by setting MOZ_REMOTE_SETTINGS_DEVTOOLS=1 in the environment
[ImapModuleLoader] Using nsImapService.cpp
*** 2024-05-05T22:49:15.429Z LOG  edscalendar.edscalendar : Loaded prefs
*** 2024-05-05T22:49:15.431Z LOG  edscalendar.libLoader : Opened libglib-2.0.so.0
*** 2024-05-05T22:49:15.431Z LOG  edscalendar.libLoader : Opened libgio-2.0.so.0
*** 2024-05-05T22:49:15.432Z LOG  edscalendar.libLoader : Opened libgobject-2.0.so.0
*** 2024-05-05T22:49:15.435Z ERROR  edscalendar.edscalendar : Cannot load edsCalendarClient
  LoadingLibException: Library libecal-2.0.so or libecal-1.2 not available. EdsCalendar requires EDS >= 0.8
  Stack:
    LoadingLibException@resource://edscalendar/legacy/modules/utils/exceptions.jsm:33:5
loadOldEdsLib@resource://edscalendar/legacy/modules/bindings/edslib.jsm:72:13
loadEdsLib@resource://edscalendar/legacy/modules/bindings/edslib.jsm:48:19
init@resource://edscalendar/legacy/modules/bindings/libedataserver.jsm:48:27
CalEdsProvider@resource://edscalendar/legacy/modules/calEdsProvider.jsm:73:22
@resource://edscalendar/legacy/modules/calEdsProvider.jsm:980:24
@resource://edscalendar/legacy/modules/edsCalendarClient.jsm:34:40
createEdsCalendarClient@jar:file:///home/username/.thunderbird/x29f33fo.default-default-1/extensions/%7Be6696d02-r32r-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js:88:49
onStartup@jar:file:///home/username/.thunderbird/x29f33fo.default-default-1/extensions/%7Be6696d02-r32r-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js:50:35


JavaScript error: jar:file:///home/username/.thunderbird/x29f33fo.default-default-1/extensions/%7Be6696d02-r32r-11e3-a162-04e36188709b%7D.xpi!/api/edsCalendar.js, line 95: Error: Cannot load edsCalendarClient
JavaScript error: undefined, line 0: Error: An unexpected error occurred
Betterbird: Detected desktop environment x-cinnamon.

I also tried the bash script method you suggested but I get this error (and I am running the flatpak run command in the same directory as the script, my home dir):

> flatpak run --command=modify_betterbird_path.sh eu.betterbird.Betterbird 
bwrap: execvp modify_betterbird_path.sh: No such file or directory

Not sure what else to try as my knowledge of the Flatpak system is limited.

Update: Interesting side-note, however, is that at some point during my testing with all of this, all my calendar data appears to have been deleted in EDS, since my Gnome calendar applet now shows no events. That's disappointing. It's still in Betterbird, though, thankfully. Something must have communicated with EDS at some point, I would imagine, for it to have deleted all those events from EDS / Gnome calendar.

@czhang03
Copy link

czhang03 commented May 6, 2024

@GalacticSun I didn't expect these results. Can you make sure that you enable the host-os storage permission, and try to run the following command for me:

# this will put you into a bash shell in the sandbox
> flatpak run --command=bash eu.betterbird.Betterbird 

# check the sandbox usr dir, I don't expect any result
[📦 eu.betterbird.Betterbird ~]$ find /usr -name libecal-2.0.so*

# check the host usr dir, I expect the three libaries listed above
[📦 eu.betterbird.Betterbird ~]$ find /run/host/usr/ -name libecal-2.0.so*

# check if the path varaible is correctly set
[📦 eu.betterbird.Betterbird ~]$ echo $PATH

If this troubleshoot don't work, I would just try to see if I can come up with a fix on my machine. Thank you for your cooperation.

@GalacticSun
Copy link

@czhang03 Thanks. Where do I enable the host-os storage permission? In Flatpak somewhere?

@czhang03
Copy link

czhang03 commented May 6, 2024

@GalacticSun You can do it like so in flatseal:
Screenshot from 2024-05-06 11-17-57

This enables read-only access to system executables, which should be enough.

Alternatively, you can also toggle "All system libraries, executables and static data" field. In theory, this toggle will enable both read and write access, but IRCC to write in system library requires root privileges, thus this option is will be de facto "read-only".

@GalacticSun
Copy link

@czhang03 Thanks. Okay, I enabled host-os storage and ran the following commands:

# this will put you into a bash shell in the sandbox
> flatpak run --command=bash eu.betterbird.Betterbird 

# check the sandbox usr dir, I don't expect any result
[📦 eu.betterbird.Betterbird ~]$ find /usr -name libecal-2.0.so*
# Correct, no results.

# check the host usr dir, I expect the three libaries listed above
[📦 eu.betterbird.Betterbird ~]$ find /run/host/usr/ -name libecal-2.0.so*
# Results:
/run/host/usr/lib/x86_64-linux-gnu/libecal-2.0.so.1.0.0
/run/host/usr/lib/x86_64-linux-gnu/libecal-2.0.so  (I left my symlink there)
/run/host/usr/lib/x86_64-linux-gnu/libecal-2.0.so.1

# check if the path varaible is correctly set
[📦 eu.betterbird.Betterbird ~]$ echo $PATH
# Result:
/run/host/lib/x86_64-linux-gnu/:/app/bin:/usr/bin

However, the error message still displays when launching Betterbird, and no events have appeared in EDS/Gnome mini calendar applet:
LoadingLibException: Library libecal-2.0.so or libecal-1.2 not available. EdsCalendar requires EDS >= 0.8

I also tried toggling the "All system libraries, executables and static data" field in Flatseal, but I still got the error message.

@GalacticSun
Copy link

Update: Actually my EDS / Gnome calendar events weren't all deleted. In my testing zeal, I forgot that I'd turned off "Show calendar events" in the Cinnamon applet options and the dots disappeared, but now they're back. But the main problem still remains: events are still not being synced between Betterbird/Thunderbird and EDS.

Any other ideas or suggestions to make this work?

@czhang03
Copy link

This is unexpected, as you have seen, the path is loaded correctly, and the required library is indeed in the path, yet it is not found by the extension.

IIRC, last time I read the source code, the code indeed tries to find the library in path. I don't know what changed or what went wrong. I am sorry, I am way too busy recently to do debug this further. I probably will try to circle back to this when I have more time.

@GalacticSun
Copy link

@czhang03 Thanks, that's okay, I really appreciate your help. I would have not been able to get this far on my own since I just don't know the Flatpak system very well. I will try again, maybe I messed up a step. Thanks again!

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

8 participants