saadtazi / firefox-profile-js

Firefox Profile creation using nodejs and CLI
MIT License
60 stars 30 forks source link

TypeError: Cannot read property 'split' of undefined in Ubuntu #136

Open Sharcoux opened 1 year ago

Sharcoux commented 1 year ago

The method readProfiles from the file profile_finder.js seems to be looking for profiles.ini to the wrong place in Ubuntu.

The file is located at /home/<me>/snap/firefox/common/.mozilla/firefox/ in my computer, but this.directory is undefined during the execution, and, anyway, the locateUserDirectory would return /home/<me>/.mozilla/firefox.

saadtazi commented 1 year ago

Hi, are you using the cli or the class ProfileFinder directly?

If you are using the class directly:

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.

Sharcoux commented 1 year ago

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...

saadtazi commented 1 year ago

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 ...

Sharcoux commented 1 year ago

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

saadtazi commented 1 year ago

Happy that your (first) issue is solved.

Good idea for snap directory. I am accepting PRs if you're interested in contributing 😃

Rob--W commented 1 year ago

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.

saadtazi commented 1 year ago

@Rob--W : you are right, I should fix that. I'll give it a try tonight.

jrom99 commented 7 months ago

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.

saadtazi commented 7 months ago

Of course, please do, no problem! If that makes you feel better, I wrote that package approximately one month after starting nodejs ☺️

saadtazi commented 7 months ago

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:

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?

saadtazi commented 7 months ago

version 4.6.0 published. Please let me know if you encounter any issue.