Closed Bug 2001887 Opened 1 month ago Closed 21 days ago

New XDG basedir support still creates an empty ~/.mozilla/extensions directory

Categories

(WebExtensions :: General, task, P2)

task

Tracking

(firefox147 verified, firefox148 verified, firefox149 verified)

VERIFIED FIXED
148 Branch
Tracking Status
firefox147 --- verified
firefox148 --- verified
firefox149 --- verified

People

(Reporter: emilio, Assigned: robwu)

References

Details

(Whiteboard: [addons-jira])

Attachments

(2 files)

STR:

  • mv ~/.mozilla ~/.mozilla-bak
  • Launch nightly

I expect a bunch of files to be under ~/.config/mozilla. That's alright and works. However the ~/.mozilla directory is resurrected and empty with a ~/.mozilla/extensions directory, which is rather weird / unexpected.

This was a review requirement change, from rob I think?

Flags: needinfo?(rob)
Duplicate of this bug: 2001830

Searching for addons in the legacy location is very much on purpose, but the problem here is the directory being created when it doesn't exist.

(In reply to :gerard-majax from comment #2)

This was a review requirement change, from rob I think?

I was never involved in the thread, perhaps you were thinking of my feedback at bug 1986219? The original request in the current bug came from :glandium at https://phabricator.services.mozilla.com/D6995#inline-1400955

The directory is being created at https://searchfox.org/firefox-main/rev/af0f713f785417023666ef557e856b3a9d132041/toolkit/xre/nsXREDirProvider.cpp#1184,1187

I wonder how many still rely on this location. It is at https://searchfox.org/firefox-main/rev/af0f713f785417023666ef557e856b3a9d132041/toolkit/mozapps/extensions/internal/XPIProvider.sys.mjs#2571-2572 (along with the lookup of a registry key on Windows only), but by default we only look up in SCOPE_PROFILE: https://searchfox.org/firefox-main/rev/af0f713f785417023666ef557e856b3a9d132041/toolkit/mozapps/extensions/internal/AddonSettings.sys.mjs#125-138 (which is enabled by default on ESR only).

Flags: needinfo?(rob)

(In reply to Rob Wu [:robwu] from comment #5)

(In reply to :gerard-majax from comment #2)

This was a review requirement change, from rob I think?

I was never involved in the thread, perhaps you were thinking of my feedback at bug 1986219? The original request in the current bug came from :glandium at https://phabricator.services.mozilla.com/D6995#inline-1400955

Oops, maybe you're right

The directory is being created at https://searchfox.org/firefox-main/rev/af0f713f785417023666ef557e856b3a9d132041/toolkit/xre/nsXREDirProvider.cpp#1184,1187

Yes, thanks, and it confirms my memory of this being already created by default prior to my changes.
While it may look weird now that we support XDG_CONFIG_HOME, it predates it. I worry some of our code down the like in XPI/extensions handling may silently break if it does not exists for real

(In reply to :gerard-majax from comment #6)

Yes, thanks, and it confirms my memory of this being already created by default prior to my changes.
While it may look weird now that we support XDG_CONFIG_HOME, it predates it. I worry some of our code down the like in XPI/extensions handling may silently break if it does not exists for real

Would regression tests catch any issues if you just disable creating it when non in legacy mode?

The severity field is not set for this bug.
:nika, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(nika)

Another issue that breaks XDG spec, just for the reference: bug #2005167.

Severity: -- → S3

(In reply to :gerard-majax from comment #6)

(In reply to Rob Wu [:robwu] from comment #5)

The directory is being created at https://searchfox.org/firefox-main/rev/af0f713f785417023666ef557e856b3a9d132041/toolkit/xre/nsXREDirProvider.cpp#1184,1187

Yes, thanks, and it confirms my memory of this being already created by default prior to my changes.
While it may look weird now that we support XDG_CONFIG_HOME, it predates it. I worry some of our code down the like in XPI/extensions handling may silently break if it does not exists for real

The add-ons manager (extensions) don't care about the existence of the directory, see least comment 5 for an explanation on its non-use (other than ESR, or with a custom pref). All uses of this path can be found here:

Given the lack of use, I think that it would be okay to disable the directory creation.

:sinker
Please do not set severity (S3) on bugs, at least not for bugs in the WebExtensions product. Assigning severity is the responsibility of the triage owners (or their team). In the WebExtensions team, our query for bugs to triage exclude bugs that already have an assigned severity. So by changing the severity of a bug, you are increasing the likelihood of the bug to be unnoticed and therefore not get looked into.

Sorry, I did these two bug by a mistake. Just fix it.

Severity: S3 → --

Seems like this is perhaps an extension issue, although the code exists within XPCOM. We can review the change from the extensions side, but I think it would just involve removing the EnsureDirectoryExists call (https://searchfox.org/firefox-main/rev/54da8f6bfead7871ca89f2cb18323af5f00d9620/toolkit/xre/nsXREDirProvider.cpp#1187) and doing some testing to ensure everything still works as expected.

Component: XPCOM → General
Flags: needinfo?(nika)
Product: Core → WebExtensions
Severity: -- → N/A
Type: defect → task
Priority: -- → P2
Whiteboard: [addons-jira]
Assignee: nobody → rob
Status: NEW → ASSIGNED
Duplicate of this bug: 732435

(In reply to Mike Kaply [:mkaply] from comment #14)

Will this fix this?

https://bugzilla.mozilla.org/show_bug.cgi?id=732435

Yes. On Windows this code path uses Mozilla\Extensions\ instead of .mozilla/extensions/ - https://searchfox.org/firefox-main/rev/f9d8702e26624ab46a35bf6561a7c8143c6f246a/toolkit/xre/nsXREDirProvider.cpp#1262-1275

Bug 732435 points to %USERPROFILE%\Mozilla\, but according to this source at https://searchfox.org/firefox-main/rev/b67c6262ecbe7d4c9385a1bd335fd7dd1d3f887d/browser/components/enterprisepolicies/Policies.sys.mjs#467-468
the path is expected to be %USERNAME\AppData\Roaming\Mozilla. Is this as expected? Has nothing to do with this bug, but since we're looking at it, I'd like to double-check.

Is this as expected? Has nothing to do with this bug, but since we're looking at it, I'd like to double-check.

Yes. Roaming is the default, so that's what %USERPROFILE%\Mozilla pointed to

Status: ASSIGNED → RESOLVED
Closed: 21 days ago
Resolution: --- → FIXED
Target Milestone: --- → 148 Branch
Attachment #9537708 - Flags: approval-mozilla-release?

firefox-release Uplift Approval Request

If someone were to try this out, they would still see Firefox creating a ~/.mozilla/ directory, in violation of that spec. So the 147 release does not match user expectations in this regards. The directory creation was unnecessary, and this patch removes that.

  • Code covered by automated testing: no
  • Fix verified in Nightly: yes
  • Needs manual QE test: yes
  • Steps to reproduce for manual QE testing: 1. On a new Linux user account (or at least one where ~/.mozilla/ was removed), start Firefox.
  1. Verify that the ~/.mozilla/ directory was not created.
  • Risk associated with taking this patch: low
  • Explanation of risk level: Removes logic that creates the empty directory. Low risk because we do not rely on the directory's existence. The only build where users can opt in to the dependent feature is ESR, and even there users can create the directory themselves if needed.
  • String changes made/needed: None
  • Is Android affected?: no
Flags: qe-verify+
QA Whiteboard: [qa-triage-done-c149/b148]
QA Contact: acornestean

Verified as Fixed. Tested on the latest Nightly (149.0a1/20260114211245) and Beta (148.0b2/20260114090336) under Ubuntu 24.10 according to the STR from Comment 21.

Using a new Linux user account where the ~/.mozilla/ directoy is non-existent, installing and starting the browser will not create the ~/.mozilla/ directory, confirming the fix.

For comparison, I’ve also tested the latest Release (147.0/20260105210555) as well. Launching this browser version without the fix, will create the ~/.mozilla/ directory as expected.

When the uplift to Firefox Release is completed, I will check once again.

Status: RESOLVED → VERIFIED
Attachment #9537708 - Flags: approval-mozilla-release? → approval-mozilla-release+

Verified as Fixed. Tested on the latest Release (147.0.1/2026011609130) under Ubuntu 24.10 according to the STR from Comment 21.

Using a new Linux user account where the ~/.mozilla/ directoy is non-existent, installing and starting the browser will not create the ~/.mozilla/ directory, confirming the fix.

Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: