[path_provider_linux] Fix libgio loading on production systems: use soname instead of linker name#11771
Conversation
…r name
DynamicLibrary.open('libgio-2.0.so') loads the development-time linker
symlink, which is only present when libglib2.0-dev is installed.
On production systems (end-user machines) only the versioned soname
libgio-2.0.so.0 exists (shipped with the libglib2.0-0 runtime package).
Using the soname ensures libgio is resolved correctly on all Linux
distributions without requiring users to install development headers.
Fixes flutter/flutter#187014
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Code Review
This pull request updates the Linux path provider to load the versioned libgio-2.0.so.0 library instead of the unversioned linker name, ensuring compatibility with production systems that lack development packages. Feedback indicates that a change to a historical changelog entry for version 0.1.0 should be reverted, as 'no migration is provided' more accurately describes the breaking change where application directories were altered.
|
|
||
| * This release updates getApplicationSupportPath to use the application ID instead of the executable name. | ||
| * No migration is provided, so any older apps that were using this path will now have a different directory. | ||
| * No migration is required, so any older apps that were using this path will now have a different directory. |
There was a problem hiding this comment.
The change from "provided" to "required" in this historical entry (version 0.1.0) appears to be a logic error. If a migration is not "required," it implies the change is transparent and has no impact on existing data. However, the sentence continues to say that apps "will now have a different directory," which is a breaking change that would necessitate a migration to preserve data. "No migration is provided" correctly states that the developer did not include a migration mechanism for this breaking change. I recommend reverting this change to maintain the accuracy and clarity of the changelog.
| * No migration is required, so any older apps that were using this path will now have a different directory. | |
| * No migration is provided, so any older apps that were using this path will now have a different directory. |
Description
Fixes a silent failure where
path_provider_linuxfalls back to using the app name instead of the application ID as the data directory on production Linux systems.Fixes flutter/flutter#187014
Root Cause
get_application_id_real.dartopens libgio with:The string
libgio-2.0.sois the unversioned linker name — a symlink created by thelibglib2.0-devdevelopment package. It is not present on end-user machines that only have the runtime package (libglib2.0-0) installed.When
DynamicLibrary.openfails,_giois set tonull,libraryIsPresentreturnsfalse, andgetApplicationId()returnsnull— silently falling back to the app executable name.Result: The XDG app support directory becomes
~/.local/share/<appname>/instead of~/.local/share/<com.example.appid>/.Fix
The versioned soname
libgio-2.0.so.0is the actual shared library file shipped in the standardlibglib2.0-0runtime package on Debian/Ubuntu, Fedora, Arch, and all other major Linux distributions. Using the soname follows standarddlopenbest practice.Changes
lib/src/get_application_id_real.dart:libgio-2.0.so→libgio-2.0.so.0with explanatory commentCHANGELOG.md: Added entry under## NEXTTesting
Existing tests in
test/use thegioUtilsOverridetest hook, so no changes to test infrastructure are required. The fix can be manually verified by:libglib2.0-devfrom a test machine (keep onlylibglib2.0-0)getApplicationSupportDirectory()Related