Skip to content

Update promptfoo package#44

Closed
roelandvh wants to merge 7 commits intomasterfrom
rvh-update-promptfoo-package
Closed

Update promptfoo package#44
roelandvh wants to merge 7 commits intomasterfrom
rvh-update-promptfoo-package

Conversation

@roelandvh
Copy link

@roelandvh roelandvh commented Jun 24, 2025

This PR attempts to fix the promptfoo package from failing to build.

Initial error:

...
error: builder for '/nix/store/zm2lfyhva9kmxajhch5xjm59ryhny66y-promptfoo-0.79.0.drv' failed with exit code 1;
       last 25 log lines:
       > node_modules/better-sqlite3/build/gyp-mac-tool: interpreter directive changed from "#!/usr/bin/env python3" to "/nix/store/v0vy1c59f0vf71h64caw17hzymvg0zms-python3-3.12.10/bin/python3"
       > node_modules/nice-napi/build/gyp-mac-tool: interpreter directive changed from "#!/usr/bin/env python3" to "/nix/store/v0vy1c59f0vf71h64caw17hzymvg0zms-python3-3.12.10/bin/python3"
       > Finished npmConfigHook
       > patchPhase completed in 42 seconds
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: buildPhase
       > no Makefile or custom buildPhase, doing nothing
       > Running phase: installPhase
       > Executing npmInstallHook
       >
       > up to date, audited 1927 packages in 3s
       >
       > 444 packages are looking for funding
       >   run `npm fund` for details
       >
       > found 0 vulnerabilities
       > Finished npmInstallHook
       > Running phase: fixupPhase
       > checking for references to /private/tmp/nix-build-promptfoo-0.79.0.drv-0/ in /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0...
       > patching script interpreter paths in /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0
       > ERROR: noBrokenSymlinks: the symlink /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0/lib/node_modules/promptfoo/node_modules/promptfoo-docs points to a missing target: /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0/lib/node_modules/promptfoo/site
       > ERROR: noBrokenSymlinks: the symlink /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0/lib/node_modules/promptfoo/node_modules/nextui points to a missing target: /nix/store/1wp25wzcig55f7xjmshymp5666gsxs64-promptfoo-0.79.0/lib/node_modules/promptfoo/src/web/nextui
       > ERROR: noBrokenSymlinks: found 2 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks
       For full logs, run 'nix log /nix/store/zm2lfyhva9kmxajhch5xjm59ryhny66y-promptfoo-0.79.0.drv'.
...

Steps taken

1. Upgrade promptfoo to newer version

The initial upgrade was done by running nix-shell -p nix-update and then inside that shell nix-update promptfoo. This updated the version number and various hashes.

2. Fix build

See the commit messages for which error each change is trying to address.

After these changes I was able to successfully build the package using nix-build -A promptfoo.

After that I was able to install promptfoo using nix-env -f . -iA promptfoo.

Finally, I was able to run promptfoo:

% nix-env -f . -iA promptfoo
installing 'promptfoo-0.115.3'
building '/nix/store/lidkacp847l2pw7g2d877ivaahqqwq96-user-environment.drv'...
% type promptfoo
promptfoo is /Users/roeland/.nix-profile/bin/promptfoo
% promptfoo --version
0.115.3

I've also tested it by trying out promptfoo eval and promptfoo view on an existing promptfooconfig.yaml.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@roelandvh roelandvh self-assigned this Jun 24, 2025
@roelandvh roelandvh marked this pull request as ready for review June 24, 2025 13:19
Comment on lines 34 to 35

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we know what creates these symlinks / why these symlinks are broken? possibly they correspond to the workspaces in package.json[1][2]? i don't know the node ecosystem super well. it looks the broken symlink check was introduced in nixpkgs somewhat recently[3]. searching rm $out/lib/node_modules in nixpkgs i see a bunch of other packages that are affected by this hook but no explanation 😕

[1] https://github.com/promptfoo/promptfoo/blob/a79652729595cf10b68253e3bce3d6d6d2ee75bd/package.json#L19-L22
[2] https://github.com/promptfoo/promptfoo/blob/a79652729595cf10b68253e3bce3d6d6d2ee75bd/site/package.json#L2
[3] NixOS#370750

i tried inspecting the homebrew promptfoo package and did not see either of those paths fwiw.

i don't think -f is required.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed both -fs (and the redundant comment).

I also don't know why these symlinks are created/broken. But with these rm ... in place I was able build and also run the resulting promptfoo version successfully for our use cases.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm okay with landing this as-is in our private repo since it appears to work. if we want to upstream this we should dig into those symlinks and understand their interaction with workspaces better. it seems like we may want to look at using yarn2nix[1] or pnpmWorkspaces[2] for proper workspace support?

[1] https://github.com/NixOS/nixpkgs/blob/2a1a028992b8430670bd473dd9011e7ed27178dc/doc/languages-frameworks/javascript.section.md?plain=1#L58
[2] https://github.com/NixOS/nixpkgs/blob/2a1a028992b8430670bd473dd9011e7ed27178dc/doc/languages-frameworks/javascript.section.md?plain=1#L507

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm okay with landing this as-is in our private repo since it appears to work.

@joshheinrichs-shopify I understand the above to mean you'd prefer not to merge this PR into Shopify/nixpkgs given it's public, but instead merge it into our own private Shopify/nixpkgs-shopify. It looks like the structure over there is slightly different. Would the following be the work involved to move this over to Shopify/nixpkgs-shopify?

  1. Add /pkgs/promptfoo/default.nix with the exact same contents as /pkgs/by-name/pr/promptfoo/package.nix in this repo.
  2. Add promptfoo = pkgs.callPackage ./pkgs/promptfoo { }; to default.nix.

Would that cover it? Anything missing or wrong?

cc @vaidas-shopify in case you're interested.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add /pkgs/promptfoo/default.nix with the exact same contents as /pkgs/by-name/pr/promptfoo/package.nix in this repo.
  2. Add promptfoo = pkgs.callPackage ./pkgs/promptfoo { }; to default.nix.

Would that cover it? Anything missing or wrong?

@roelandvh yes, this looks right

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've created said PR here.

@roelandvh roelandvh force-pushed the rvh-update-promptfoo-package branch from 7926be1 to 2a1a028 Compare June 24, 2025 14:50
Copy link

@vaidas-shopify vaidas-shopify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Let's move updated package to https://github.com/Shopify/nixpkgs-shopify
  2. In the mean time it would be great to open PR on the nixpkgs upstream

This was done by running `nix-shell -p nix-update` and then from inside that shell, running `nix-update promptfoo`.
This solves the following error:
```
...
error: builder for '/nix/store/10zk098dm6s6wxj73a3vfd6bqklywbq9-promptfoo-0.115.1.drv' failed with exit code 1;
       last 25 log lines:
       > npm error }
       > npm error Error: unable to get local issuer certificate
       > npm error     at TLSSocket.onConnectSecure (node:_tls_wrap:1679:34)
       > npm error     at TLSSocket.emit (node:events:518:28)
       > npm error     at TLSSocket._finishInit (node:_tls_wrap:1078:8)
       > npm error     at ssl.onhandshakedone (node:_tls_wrap:864:12) {
       > npm error   code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
       > npm error }
       > npm error /private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/index.js:1096
       > npm error       throw new Error(`Failed to download ${title}, caused by
       > npm error             ^
       > npm error
       > npm error Error: Failed to download Chromium 136.0.7103.25 (playwright build v1169), caused by
       > npm error Error: Download failure, code=1
       > npm error     at ChildProcess.<anonymous> (/private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/browserFetcher.js:94:32)
       > npm error     at ChildProcess.emit (node:events:518:28)
       > npm error     at ChildProcess._handle.onexit (node:internal/child_process:293:12)
       > npm error     at /private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/index.js:1096:13
       > npm error     at async Registry._downloadExecutable (/private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/index.js:1095:5)
       > npm error     at async Registry.install (/private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/index.js:989:9)
       > npm error     at async installBrowsersForNpmInstall (/private/tmp/nix-build-promptfoo-0.115.1.drv-0/source/node_modules/playwright-core/lib/server/registry/index.js:1220:3)
       > npm error
       > npm error Node.js v22.14.0
       > npm error Log files were not written due to an error writing to the directory: /nix/store/k6gxiw6p3rfy2xwv1r2z1z5za4sr8r15-promptfoo-0.115.1-npm-deps/_logs
       > npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
       For full logs, run 'nix log /nix/store/10zk098dm6s6wxj73a3vfd6bqklywbq9-promptfoo-0.115.1.drv'.
```
This solves the following error:
```
...
error: builder for '/nix/store/jjn5jckyrbbf1lbl7sy3jylhkvckg6vl-promptfoo-0.115.1.drv' failed with exit code 1;
       last 25 log lines:
       > patching script interpreter paths in node_modules
       > node_modules/better-sqlite3/build/gyp-mac-tool: interpreter directive changed from "#!/usr/bin/env python3" to "/nix/store/vfdk6q81hdjqjfiqz8f92hibdck3kmn6-python3-3.12.10/bin/python3"
       > Finished npmConfigHook
       > patchPhase completed in 38 seconds
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: buildPhase
       > no Makefile or custom buildPhase, doing nothing
       > Running phase: installPhase
       > Executing npmInstallHook
       >
       > up to date, audited 748 packages in 9s
       >
       > 87 packages are looking for funding
       >   run `npm fund` for details
       >
       > found 0 vulnerabilities
       > Finished npmInstallHook
       > Running phase: fixupPhase
       > checking for references to /private/tmp/nix-build-promptfoo-0.115.1.drv-0/ in /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1...
       > patching script interpreter paths in /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1
       > ERROR: noBrokenSymlinks: the symlink /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1/lib/node_modules/promptfoo/node_modules/app points to a missing target: /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1/lib/node_modules/promptfoo/src/app
       > ERROR: noBrokenSymlinks: the symlink /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1/lib/node_modules/promptfoo/node_modules/promptfoo-docs points to a missing target: /nix/store/p8ps9pmbm3mkgjh1z5y250wpdcwfwcrw-promptfoo-0.115.1/lib/node_modules/promptfoo/site
       > ERROR: noBrokenSymlinks: found 2 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks
       For full logs, run 'nix log /nix/store/jjn5jckyrbbf1lbl7sy3jylhkvckg6vl-promptfoo-0.115.1.drv'.
```
Without this, promptfoo would fail to run with this error:
```
% promptfoo --version
node:internal/modules/cjs/loader:1404
  throw err;
  ^

Error: Cannot find module '/nix/store/hxl79bpga73qz4z6pcxd903b6b0xbnrb-promptfoo-0.115.3/lib/node_modules/promptfoo/dist/src/main.js'
    at Function._resolveFilename (node:internal/modules/cjs/loader:1401:15)
    at defaultResolveImpl (node:internal/modules/cjs/loader:1057:19)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1062:22)
    at Function._load (node:internal/modules/cjs/loader:1211:37)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
    at node:internal/main/run_main_module:36:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
```
Also, remove redundant comment.
This was done by running `nix-shell -p nix-update` and then from inside that shell, running `nix-update promptfoo`.
@roelandvh roelandvh force-pushed the rvh-update-promptfoo-package branch from 2a1a028 to 3ca9d64 Compare June 25, 2025 12:25
@roelandvh
Copy link
Author

@roelandvh roelandvh closed this Jun 25, 2025
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

Successfully merging this pull request may close these issues.

3 participants