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

Opening firefox on mac m1 fails to start with error #14

Open
masonedmison opened this issue Aug 5, 2024 · 9 comments
Open

Opening firefox on mac m1 fails to start with error #14

masonedmison opened this issue Aug 5, 2024 · 9 comments

Comments

@masonedmison
Copy link

Hi,

I'm on a Macbook Pro with a M1 processor. I'm using the overlay provided in this repo in my flake. When I open up the application (e.g. with open ~/.nix-profile/Applications/Firefox.app/Contents/MacOS/firefox), I get the following error:

/nix/store/ar2628mhd949a5i95sbvsn1x4gn941r6-Firefox-128.0.3/Applications/Firefox.app/Contents/MacOS/firefox ; exit;
chruby: unknown Ruby: ruby-3.1.1
edmisml% /nix/store/ar2628mhd949a5i95sbvsn1x4gn941r6-Firefox-128.0.3/Applications/Firefox.app/Contents/MacOS/firefox ; exit;
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable

It looks like a ruby dependency is missing.

@rhoriguchi
Copy link

Same issue on M3

 > /nix/Store/z8q4zaf5y3b96hywb8rlp0zc0b3vba42-Firefox-129.0/Applications/Firefox.app/Contents/MacOS/firefox
 UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable

@JayRovacsek
Copy link

JayRovacsek commented Aug 23, 2024

@masonedmison @rhoriguchi, do you both use nix-darwin's programs.firefox option by chance? A bit of testing recently I seem to have found that it generates a profiles.ini file that looks like the following:

[General]
StartWithLastProfile=1
Version=2

[Profile0]
Default=1
IsRelative=1
Name=foo
Path=Profiles/foo

When I removed all traces of Firefox (akin to: rm -rf ~/Library/Application\ Support/Firefox) and launched Firefox; it launched correctly via these builds and generated the following profiles.ini file:

[Profile1]
Name=default
IsRelative=1
Path=Profiles/sq26cl1i.default
Default=1

[Install9C25CD3BE4EC07E3]
Default=Profiles/gnhvasys.default-release
Locked=1

[Profile0]
Name=default-release
IsRelative=1
Path=Profiles/gnhvasys.default-release

[General]
StartWithLastProfile=1
Version=2

Which led me to probe at the existence of the [InstallXXXX] attribute; failing to understand how to correctly identify the Firefox code that handles this, I simply tested lib.mkForce on the generated home.file attribute (ref) that is as below:

home.file."Library/Application Support/Firefox/profiles.ini" = let 
    profiles = lib.flip lib.mapAttrs' cfg.profiles (_: profile:
    lib.nameValuePair "Profile${toString profile.id}" {
      Name = profile.name;
      Path = if pkgs.stdenv.isDarwin then "Profiles/${profile.path}" else profile.path;
      IsRelative = 1;
      Default = if profile.isDefault then 1 else 0;
    }) // {
      General = { StartWithLastProfile = 1; };
    };

  profile-ini = lib.generators.toINI { } profiles;
  in 
  {
    enable = true;
    text = lib.mkForce profile-ini;
  };

edit: the below code suggestion is incorrect - the issue seems to stem from the version property

After which the application seems to launch correctly. In TLDR, does the following addition to profile.ini change your current experience (where foo is your profile name?:

[Install]
Default=Profiles/foo
Locked=1

@JayRovacsek
Copy link

JayRovacsek commented Aug 23, 2024

Ah! Related: nix-community/home-manager#5717

edit; yep! The above seems to be my cause also

@rhoriguchi
Copy link

rhoriguchi commented Aug 28, 2024

Yes, I'm using nix-darwin but I'm running the same config on my Linux machine with no issue. So I think the linked issue is the culprit @JayRovacsek

@calops
Copy link

calops commented Sep 13, 2024

nix-community/home-manager#5717 (comment)

Quick workaround is to set MOZ_LEGACY_PROFILES=1. This could easily be done in this flake in a wrapper, until it's fixed upstream.

@JayRovacsek
Copy link

nix-community/home-manager#5717 (comment)

Quick workaround is to set MOZ_LEGACY_PROFILES=1. This could easily be done in this flake in a wrapper, until it's fixed upstream.

Ah, this is a really neat way compared to what I'd suggested above, thanks!

@calops
Copy link

calops commented Oct 3, 2024

Alright, so, on my system I can launch firefox like this:

MOZ_LEGACY_PROFILES=1 ~/Applications/Home\ Manager\ Apps/Firefox.app/Contents/MacOS/firefox

And it works as expected. However, I've tried to do it in a more streamlined way in my config:

pkgs.firefox-beta-bin.overrideAttrs {
  nativeBuildInputs = [ pkgs.makeBinaryWrapper ];
  postInstall = ''
    wrapProgram $out/Applications/Firefox.app/Contents/MacOS/firefox --set MOZ_LEGACY_PROFILES 1
  '';
}

This produces the correct wrapper, however... it automatically sends a SIGKILL to the program whenever we try to run it. I imagine it's MacOS killing it automatically because of the program's signature being different, or something like that? Which makes sense, but I don't see any workaround for this.

@Yumekui
Copy link

Yumekui commented Dec 9, 2024

For anyone encountering this issue, this fixes it for me:

launchd.user.envVariables = {
  MOZ_LEGACY_PROFILES = "1";
};

@ayorgo
Copy link

ayorgo commented Dec 14, 2024

home.sessionVariables = {
  MOZ_LEGACY_PROFILES = "1";
};

in home.nix fixed it for me.

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

6 participants