Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
- Add
/pkgs/promptfoo/default.nixwith the exact same contents as/pkgs/by-name/pr/promptfoo/package.nixin this repo. - Add
promptfoo = pkgs.callPackage ./pkgs/promptfoo { };todefault.nix.
Would that cover it? Anything missing or wrong?
cc @vaidas-shopify in case you're interested.
There was a problem hiding this comment.
- Add
/pkgs/promptfoo/default.nixwith the exact same contents as/pkgs/by-name/pr/promptfoo/package.nixin this repo.- Add
promptfoo = pkgs.callPackage ./pkgs/promptfoo { };todefault.nix.Would that cover it? Anything missing or wrong?
@roelandvh yes, this looks right
7926be1 to
2a1a028
Compare
vaidas-shopify
left a comment
There was a problem hiding this comment.
- Let's move updated package to https://github.com/Shopify/nixpkgs-shopify
- 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.
Also, remove redundant comment.
This was done by running `nix-shell -p nix-update` and then from inside that shell, running `nix-update promptfoo`.
2a1a028 to
3ca9d64
Compare
|
Closing this PR in favor of https://github.com/Shopify/nixpkgs-shopify/pull/11 . |
This PR attempts to fix the
promptfoopackage from failing to build.Initial error:
Steps taken
1. Upgrade
promptfooto newer versionThe initial upgrade was done by running
nix-shell -p nix-updateand then inside that shellnix-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:I've also tested it by trying out
promptfoo evalandpromptfoo viewon an existingpromptfooconfig.yaml.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.