Open Sharcoux opened 1 year ago
Hi, are you using the cli
or the class ProfileFinder
directly?
If you are using the class directly:
new
keyword to create the instance? that could explain why this
is undefined.const ProfileFinder = require('./lib/profile_finder');
console.log('>>> ProfileFinder', ProfileFinder);
const p = new ProfileFinder('some/custom/path');
console.log(p);
note: I no longer use that project, but I accept, review PRs and make new releases.
I'm actually using the web-ext
command line module from Mozilla that relies on that project. They seem to be using the ProfileFinder class. Besides that, they do things I'm not fully understanding...
Is there a flag that allows to provide profile directory using the cli? According to the doc, the flag -p
(--firefox-profile
) allows you to specify an absolute path or a profile name. Did you try that flag with an absolute path? something like npx web-ext -p /home/<me>/snap/firefox/common/.mozilla/firefox/your-profile-dir ...
Yes. But anyway, after I fix the path, I end up with: this issue which is not related to your lib.
The only thing that might be done in this lib is to update locateUserDirectory
so that it also check in ~/snap/firefox/common/.mozilla/firefox/
if it was not found in ${HOME}/.mozilla/firefox
Happy that your (first) issue is solved.
Good idea for snap
directory. I am accepting PRs if you're interested in contributing 😃
Copy-pasting from https://github.com/mozilla/web-ext/issues/2826#issuecomment-1739150954:
The error is in firefox-profile: https://github.com/saadtazi/firefox-profile-js/blob/932b40ea8758f22b938af653709767e50a26b98d/lib/profile_finder.js#L55-L57
When reading the file fails (e.g. due to it not existing), supposedly a callback should be called with the error. At line 56, the logic should not only invoke the callback with the error, but also return. Not returning results in the next line trying to parse non-existing content, which results in the error seen above.
@Rob--W : you are right, I should fix that. I'll give it a try tonight.
Hello, would it be ok if I provided a PR on this? I'd like to also provide support for the XDG spec in linux (https://bugzilla.mozilla.org/show_bug.cgi?id=1725011), but I'm not well versed in JS so it might be too amateurish.
Of course, please do, no problem! If that makes you feel better, I wrote that package approximately one month after starting nodejs ☺️
Actually, I opened a PR that should fix it (I hope you didn't spend to much time working on it already). Do you have an easy way on your end to test the fix? I do not heve an ubuntu environment.
I can think of a couple of options to test it:
npm install saadtazi/firefox-profile-js#fix/ubuntu-path --save
could work, but it depends how and where (which package) the firefox-profile dependency is specified: installing firefox-profile
at the root might not affect the installation if it is a dependencies of another package...nodule_modules/
firefox-profile
package is installed andadd the extra lines from the PR to your node_modules/firefox-profile/profile_finder.js
(or replace the profile_finder.js
file with this one)If it works, I'll publish a new package version (not sure where the firefox-profile version number will have to be updated then... in web-ext here I believe?
The method
readProfiles
from the fileprofile_finder.js
seems to be looking forprofiles.ini
to the wrong place in Ubuntu.The file is located at
/home/<me>/snap/firefox/common/.mozilla/firefox/
in my computer, butthis.directory
is undefined during the execution, and, anyway, thelocateUserDirectory
would return/home/<me>/.mozilla/firefox
.