Skip to content

[path_provider_linux] Fix libgio loading on production systems: use soname instead of linker name#11771

Open
AkshatRaj00 wants to merge 1 commit into
flutter:mainfrom
AkshatRaj00:fix/path-provider-linux-libgio-soname
Open

[path_provider_linux] Fix libgio loading on production systems: use soname instead of linker name#11771
AkshatRaj00 wants to merge 1 commit into
flutter:mainfrom
AkshatRaj00:fix/path-provider-linux-libgio-soname

Conversation

@AkshatRaj00
Copy link
Copy Markdown

Description

Fixes a silent failure where path_provider_linux falls 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.dart opens libgio with:

// BEFORE — linker name (development symlink only)
_gio = DynamicLibrary.open('libgio-2.0.so');

The string libgio-2.0.so is the unversioned linker name — a symlink created by the libglib2.0-dev development package. It is not present on end-user machines that only have the runtime package (libglib2.0-0) installed.

When DynamicLibrary.open fails, _gio is set to null, libraryIsPresent returns false, and getApplicationId() returns null — 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

// AFTER — versioned soname (present in runtime package on all distros)
_gio = DynamicLibrary.open('libgio-2.0.so.0');

The versioned soname libgio-2.0.so.0 is the actual shared library file shipped in the standard libglib2.0-0 runtime package on Debian/Ubuntu, Fedora, Arch, and all other major Linux distributions. Using the soname follows standard dlopen best practice.


Changes

  • lib/src/get_application_id_real.dart: libgio-2.0.solibgio-2.0.so.0 with explanatory comment
  • CHANGELOG.md: Added entry under ## NEXT

Testing

Existing tests in test/ use the gioUtilsOverride test hook, so no changes to test infrastructure are required. The fix can be manually verified by:

  1. Removing libglib2.0-dev from a test machine (keep only libglib2.0-0)
  2. Running a Flutter Linux app that calls getApplicationSupportDirectory()
  3. Confirm the returned path contains the application ID, not just the app name

Related


Note to reviewers: This is a 1-character change in the library name string. The fix is safe: libgio-2.0.so.0 has been the stable soname since GLib 2.x and is guaranteed to be present wherever libgio is installed at runtime.

…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
@flutter-dashboard
Copy link
Copy Markdown

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.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
* 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[path_provider_linux] App data directory falls back to app name instead of application ID when libgio link name is absent

1 participant