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

Build failure: ghostscript-10.04.0 #355377

Open
anned20 opened this issue Nov 12, 2024 · 24 comments · Fixed by #358079
Open

Build failure: ghostscript-10.04.0 #355377

anned20 opened this issue Nov 12, 2024 · 24 comments · Fixed by #358079
Assignees
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin

Comments

@anned20
Copy link

anned20 commented Nov 12, 2024

Steps To Reproduce

Steps to reproduce the behavior:

  1. build ghostscript-10.04.0

Build log

rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gsbj.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gsdj.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/eps2eps.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gsdj500.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gslj.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf14.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf13.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf12.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
@nix { "action": "setPhase", "phase": "installCheckPhase" }
Running phase: installCheckPhase
dyld[68823]: Library not loaded: libgs.10.dylib
  Referenced from: <497CFDBA-A6D1-332C-B983-C3CFF6293055> /nix/store/ag7vqbvj1pk7lqczyc3h9ynwv3y199z8-ghostscript-10.04.0/bin/gs
  Reason: tried: 'libgs.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgs.10.dylib' (no such file), 'libgs.10.dylib' (no such file), '/usr/local/lib/libgs.10.dylib' (no such file), '/usr/lib/libgs.10.dylib' (no such file, not in dyld cache), '/private/tmp/nix-build-ghostscript-10.04.0.drv-0/ghostscript-10.04.0/libgs.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/tmp/nix-build-ghostscript-10.04.0.drv-0/ghostscript-10.04.0/libgs.10.dylib' (>
/nix/store/vrjr8rg1gsvvncgdl7qybh5h7vgqdxvn-stdenv-darwin/setup: line 1596: 68823 Abort trap: 6           $out/bin/gs --version

Notify maintainers

@tobim

Metadata

  • system: "aarch64-darwin"
  • host os: Darwin 24.1.0, macOS 15.1
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.18.8
  • nixpkgs: /nix/store/dxdcvjnvz3b91gvsrhpb7gp156nnj8bf-source

Add a 👍 reaction to issues you find important.

@anned20 anned20 added the 0.kind: build failure A package fails to build label Nov 12, 2024
@FliegendeWurst FliegendeWurst added the 6.topic: darwin Running or building packages on Darwin label Nov 12, 2024
@carlocab
Copy link

The way MacPorts handles this might help: https://github.com/macports/macports-ports/blob/d8a05520fa6a81fa5b0365068590aff184976b69/print/ghostscript/Portfile#L114

So adding

DARWIN_LDFLAGS_SO_PREFIX=$out/lib/

to the build environment should fix it.

@tobim
Copy link
Contributor

tobim commented Nov 13, 2024

Hey, thanks for reporting this. I'll try to find some time to take a look in a couple of hours.

@dereulenspiegel
Copy link

Hello :)

Just wanted to mention that this also happens on x86_64-darwin.

@tobim
Copy link
Contributor

tobim commented Nov 14, 2024

The linked PR should fix that too.

@nolith
Copy link

nolith commented Nov 19, 2024

The linked PR doesn't work for me, it gets me past the compiles stage, but the binary keeps failing in the same way.

@chkpwd
Copy link

chkpwd commented Nov 19, 2024

The linked PR is not working for me either.

@ironicbadger
Copy link
Contributor

Adding the flag to the build env does not resolve this.

error: builder for '/nix/store/08gjpy7gfpylh2m2dyhasd0l5i3y7mz2-ghostscript-10.04.0.drv' failed with exit code 134;
       last 10 log lines:
       > rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gsdj500.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
       > rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/gslj.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
       > rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf14.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
       > rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf13.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
       > rewriting symlink /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man/share/man/man1/ps2pdf12.1.gz to be relative to /nix/store/58s4hjjydcvld4zcqha58ziwjybkfyvw-ghostscript-10.04.0-man
       > Running phase: installCheckPhase
       > dyld[74114]: Library not loaded: libgs.10.dylib
       >   Referenced from: <497CFDBA-A6D1-332C-B983-C3CFF6293055> /nix/store/ag7vqbvj1pk7lqczyc3h9ynwv3y199z8-ghostscript-10.04.0/bin/gs
       >   Reason: tried: 'libgs.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgs.10.dylib' (no such file), 'libgs.10.dylib' (no such file), '/usr/local/lib/libgs.10.dylib' (no such file), '/usr/lib/libgs.10.dylib' (no such file, not in dyld cache), '/private/tmp/nix-build-ghostscript-10.04.0.drv-0/ghostscript-10.04.0/libgs.10.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/private/tmp/nix-build-ghostscript-10.04.0.drv-0/ghostscript-10.04.0/libgs.10.dylib' (no such file), '/private/tmp/nix-build-ghostscript-10.04.0.drv-0/ghostscript-10.04.0/libgs.10.dylib' (no such file), '/usr/local/lib/libgs.10.dylib' (no such file), '/usr/lib/libgs.10.dylib' (no such file, not in dyld cache)
       > /nix/store/vrjr8rg1gsvvncgdl7qybh5h7vgqdxvn-stdenv-darwin/setup: line 1596: 74114 Abort trap: 6           $out/bin/gs --version
       For full logs, run 'nix log /nix/store/08gjpy7gfpylh2m2dyhasd0l5i3y7mz2-ghostscript-10.04.0.drv'.
error: 1 dependencies of derivation '/nix/store/6gcycvihj5ky3pd2s99755am38vhypy5-python3.11-matplotlib-3.8.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xsi2ys3f1cfmpjrmf6ybr5kwp980x430-python3.11-pytest-regressions-2.5.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7b8n97g22jb5spldvdi4j9hzjcm4zdrw-python3.11-markdown-it-py-3.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9qnj0p209f698v6wi2al9r8nyrdd603l-python3.11-rich-13.7.1.drv' failed to build
error: 1 dependencies of derivation '/nix/store/j38d4yy02w8cjv9byljpf0qmamdcf1ad-python3.11-executing-2.1.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k0j93dyp9c3mys8ab3w0a31y54zlixsp-python3.11-tqdm-4.66.4.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xrprmwj0q9wgq88vlc8xq8wa4bddkxzg-python3.11-icecream-2.1.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ajm4bdz068jbsczc2cfyliwvgf66m2gb-python3.11-python-on-whales-0.69.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/fnb0gmaksgs3p4d1m8bkf1xvavhmcyqg-python3.11-stack-data-0.6.3.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xr0jvhj6i64kycldhw8sy142fbxk121n-python3.11-aiohttp-3.9.5.drv' failed to build
error: 1 dependencies of derivation '/nix/store/iqhk5dlz9lz1dgbnc7yhi1csfzclscsk-python3.11-ipython-8.24.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/8gpxm2qr5y0gqxl19rxazb8z2ybsm5a4-python3.11-paramiko-3.4.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lr5abl2b7d485l2qpgcy13bslf32p68n-python3.11-ansible-core-2.16.5.drv' failed to build
error: 1 dependencies of derivation '/nix/store/r77vndv5bnfn143b4x7jcac98fsqls5m-system-applications.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xjaj2jjpslmx2aik8dahq0lsicxmfms7-darwin-system-24.05.20241116.e8c38b7+darwin5.61cee20.drv' failed to build
error: Recipe `build` failed on line 11 with exit code 1

@chkpwd
Copy link

chkpwd commented Nov 20, 2024

@ironicbadger what package does this fail for?

@ironicbadger
Copy link
Contributor

It looks like ghostscript. But for what that is a dependency for I am not sure. Do you know how to help me pinpoint?

@chkpwd
Copy link

chkpwd commented Nov 20, 2024

For me, it fails for ansible-lint. Which requires ghostscript as a deps.

@simonvreed
Copy link

For me, ghostscript-10-04-0 fails for:

  • ansible
  • python311Packages.black
  • python311Packages.isort
  • python311Packages.pylint
  • python312Packages.black
  • python312Packages.isort
  • python312Packages.pylint

@carlocab
Copy link

The fix I suggested in #355377 (comment) should resolve these failures, and remove the need to set DYLD_LIBRARY_PATH from #355853.

@ironicbadger
Copy link
Contributor

So setting this an env var on the Mac in question before doing the build? If so, that didn't work.

@elsbrock
Copy link

No, it needs to be set in the package definition during build. Builds are isolated from your env.

@chkpwd
Copy link

chkpwd commented Nov 20, 2024

@elsbrock @carlocab I'm sorry, but I'm failing to understand how we should approach this.

Below is a snippet of the problematic nix code. If I'm not supposed to pass the env to the command, what am I supposed to do?

Do I create an overlay instead?

Example:

{
  lib,
  pkgs,
  config,
  ...
}:
let
  inherit (lib) mkEnableOption mkIf;
  cfg = config.local.packages;
in
{
  options.local.packages = {
    enableDevTools = mkEnableOption "Enable dev tools";
  };

  config = mkIf cfg.enableDevTools {
    environment.systemPackages = with pkgs; [...];

    users.users.${config.crossSystem.username}.packages = with pkgs; [
      terraform
      (python312.withPackages (ps: [
        ps.pip
        ps.ansible-core
      ]))
      ansible-lint # Fails because of this
    ];
  };
}

@ironicbadger
Copy link
Contributor

No, it needs to be set in the package definition during build. Builds are isolated from your env.

How?

@nolith
Copy link

nolith commented Nov 21, 2024

If my understanding is correct, it is not a build time problem.

At runtime, ghostscripts expects to find libgs and it cannot find it.

In #355853 we are fixing the check but not the binary.

There is a post install check that runs gs and it fails because of the missing lib, so we set DYLD_LIBRARY_PATH=$out/lib, and now the check is green, but as soon as something else tries to use it, it fails again.

I'm a newbie of nix, but I think the derivation should add something like wrapProgram $out/bin/gs --set DYLD_LIBRARY_PATH $out/lib in the postBuild if we are on macOS.

@carlocab
Copy link

I'm a newbie of nix, but I think the derivation should add something like wrapProgram $out/bin/gs --set DYLD_LIBRARY_PATH $out/lib in the postBuild if we are on macOS.

This solution doesn't scale, because every binary that links with libgs.dylib (or other ghostscript libraries) will need to do something like this. It doesn't work as-is for libraries that link to libgs.dylib either.

The right thing to do is to build the ghostscript libraries with the correct install names. This can be done using the approach suggested at #355377 (comment). Or you can use install_name_tool, but you probably don't want to patch binaries if you can avoid it.

@nolith
Copy link

nolith commented Nov 21, 2024

There was an error in the install_name_tool that was not setting the correct load path for libgs.10.dylib is was using libgs.dylid.10.04 and because of that it had no effects.

#357951 fixes that for me, my gs is now working.

carlocab added a commit to carlocab/nixpkgs that referenced this issue Nov 22, 2024
Fixes NixOS#355377.

This should avoid the need to mess around with `install_name_tool`
entirely. This mirrors what is done by Homebrew[^1] and MacPorts[^2].

This should also make the changes in NixOS#355853 and NixOS#357951 unnecessary.

[^1]: https://github.com/Homebrew/homebrew-core/blob/5ca4f8ce766c69d49321fb7da1d297b8232f40cf/Formula/g/ghostscript.rb#L76
[^2]: https://github.com/macports/macports-ports/blob/d8a05520fa6a81fa5b0365068590aff184976b69/print/ghostscript/Portfile#L114
@chrishrb
Copy link

how can I apply this fix from #358079 in my current config which uses nixos-unstable for all ghostscript dependencies till this PR is merged?

@HPRIOR
Copy link

HPRIOR commented Nov 23, 2024

how can I apply this fix from #358079 in my current config which uses nixos-unstable for all ghostscript dependencies till this PR is merged?

If you are using flakes you will need to use an overlay. Roughly:

  inputs = {
    ...
    ghostscript-fix = {
      url = "github:carlocab/nixpkgs/fix-ghostscript"; 
    };
    ...
  };
outputs = {
    ...
    ghostscript-fix,
  }:
...
            nixpkgs.overlays = [
              (final: prev: {
                ghostscript = ghostscript-fix.legacyPackages.${prev.system}.ghostscript;
              })
            ];
...

This is working on my system: HPRIOR/nix-config@e517dd1

@vodium-vastro
Copy link

Issue appears linked to any application that requires python e.g. ansible (as mentioned by @ironicbadger), borgmatic, kitty etc.

My build work fine when I remove any of those apps.

I have tried applying the overlay and the build no longer fails on ghostscript-10.04.0 but then fails on bulding some apps based on python e.g.

Building nix-darwin config...
nix --extra-experimental-features 'nix-command flakes'  build ".#darwinConfigurations.Virtuous-Dynamite.system" 
error: builder for '/nix/store/zbal30xk74avsmlgavbbw06zvklxs8sd-borgbackup-1.4.0.drv' failed with exit code 1;
       last 10 log lines:
       > /nix/store/xklks5naxqwf3vbnnf4slppymnwl1shi-borgbackup-1.4.0/lib/python3.11/site-packages/borg/testsuite/xattr.py:64:
       > _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
       > /nix/store/xklks5naxqwf3vbnnf4slppymnwl1shi-borgbackup-1.4.0/lib/python3.11/site-packages/borg/testsuite/xattr.py:28: in assert_equal_se
       >     self.assert_equal(is_x, want_x)
       > E   AssertionError: Items in the first set but not the second:
       > E   b'com.apple.provenance'
       > =========================== short test summary info ============================
       > FAILED xattr.py::XattrTestCase::test - AssertionError: Items in the first set but not the second:
       > FAILED xattr.py::XattrTestCase::test_listxattr_buffer_growth - AssertionError: Items in the first set but not the second:
       > ============ 2 failed, 1290 passed, 278 skipped in 91.88s (0:01:31) ============
       For full logs, run 'nix log /nix/store/zbal30xk74avsmlgavbbw06zvklxs8sd-borgbackup-1.4.0.drv'.
error: 1 dependencies of derivation '/nix/store/9p5gfwki4035v6g3grj8ry08rsljj7gr-system-applications.drv' failed to build
error: 1 dependencies of derivation '/nix/store/ahcs5rkj4n30cg4p3rk7y1yfqlr9gnb6-darwin-system-24.05.20241116.e8c38b7+darwin4.698a62c.drv' failed to build
error: Recipe `build` failed on line 11 with exit code 1

I excluded borgbackup and tried again, ansible installed ok but it took a while. It appeared to build the package from source.

@RootMePLS
Copy link

RootMePLS commented Nov 24, 2024

After switching to 24.11 all errors disappeared

emilazy pushed a commit that referenced this issue Nov 25, 2024
Fixes #355377.

This should avoid the need to mess around with `install_name_tool`
entirely. This mirrors what is done by Homebrew[^1] and MacPorts[^2].

This should also make the changes in #355853 and #357951 unnecessary.

[^1]: https://github.com/Homebrew/homebrew-core/blob/5ca4f8ce766c69d49321fb7da1d297b8232f40cf/Formula/g/ghostscript.rb#L76
[^2]: https://github.com/macports/macports-ports/blob/d8a05520fa6a81fa5b0365068590aff184976b69/print/ghostscript/Portfile#L114
osnyx pushed a commit to flyingcircusio/nixpkgs that referenced this issue Nov 25, 2024
Fixes NixOS#355377.

This should avoid the need to mess around with `install_name_tool`
entirely. This mirrors what is done by Homebrew[^1] and MacPorts[^2].

This should also make the changes in NixOS#355853 and NixOS#357951 unnecessary.

[^1]: https://github.com/Homebrew/homebrew-core/blob/5ca4f8ce766c69d49321fb7da1d297b8232f40cf/Formula/g/ghostscript.rb#L76
[^2]: https://github.com/macports/macports-ports/blob/d8a05520fa6a81fa5b0365068590aff184976b69/print/ghostscript/Portfile#L114

(cherry picked from commit 8b3d3d5)
@szethh
Copy link

szethh commented Nov 26, 2024

as @HPRIOR said, adding the overlay fixed it for me. I also had to apply another one to fix p11-kit, which was also failing:

# darwin.nix

nixpkgs.overlays = [
    (final: prev: {
      ghostscript = ghostscript-fix.legacyPackages.${prev.system}.ghostscript;

      p11-kit = prev.p11-kit.overrideAttrs (oldAttrs: {
        mesonCheckFlags = oldAttrs.mesonCheckFlags or [ ] ++ [
          "--timeout-multiplier"
          "0"
        ];
      });
    })
  ];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

Successfully merging a pull request may close this issue.