Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Sharcoux opened this issue Jul 24, 2023 · 11 comments
Open

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

Sharcoux opened this issue Jul 24, 2023 · 11 comments

Comments

@Sharcoux
Copy link

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
Copy link
Owner

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

If you are using the class directly:

  • do you provide a custom path during instanciation
  • do you use the 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.

@Sharcoux
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

Happy that your (first) issue is solved.

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

@Rob--W
Copy link

Rob--W commented Sep 28, 2023

Copy-pasting from mozilla/web-ext#2826 (comment):

The error is in firefox-profile:

fs.readFile(path.join(this.directory, 'profiles.ini'), {encoding: 'utf8'}, function(err, data) {
if (err) { cb(err); }
Object.entries(ini.parse(data)).forEach(function ([key, value]) {

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
Copy link
Owner

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

@jrom99
Copy link

jrom99 commented Apr 4, 2024

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
Copy link
Owner

saadtazi commented Apr 4, 2024

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

@saadtazi
Copy link
Owner

saadtazi commented Apr 4, 2024

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:

  • force the installation of the PR branch: something like 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...
  • maybe just locate in which 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?

@saadtazi
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants