Need help packaging a Dart package: yq: error: argument files: can't open 'pubspec.yaml'

I’m trying to package Dart Frog CLI, but I keep getting the following error:

❯ nix build -f dartfrog4nix.nix 
error: Cannot build '/nix/store/g04i0a85ifs3c9w69z7l3f9g3cxiys8w-dart-frog-cli-1.2.
11-package-config-with-root.json.drv'.
       Reason: builder failed with exit code 2.
       Output paths:
         /nix/store/21kfxd9jy2nbnysf62kqh9zsd3z5f8q8-dart-frog-cli-1.2.11-package-c
onfig-with-root.json
       Last 14 log lines:
       > Running phase: unpackPhase
       > unpacking source archive /nix/store/nm2j50nvvczd4l80sqz5fnn4vs4vs0v0-sourc
e
       > source root is source
       > Running phase: patchPhase
       > Running phase: updateAutotoolsGnuConfigScriptsPhase
       > Running phase: configurePhase
       > no configure script, doing nothing
       > Running phase: installPhase
       > usage: yq [-h] [--yaml-output] [--yaml-roundtrip]
       >           [--yaml-output-grammar-version {1.1,1.2}] [--width WIDTH]
       >           [--indentless-lists] [--explicit-start] [--explicit-end]
       >           [--in-place] [--version]
       >           [jq_filter] [files ...]
       > yq: error: argument files: can't open 'pubspec.yaml': [Errno 2] No such fi
le or directory: 'pubspec.yaml'
       For full logs, run:
         nix log /nix/store/g04i0a85ifs3c9w69z7l3f9g3cxiys8w-dart-frog-cli-1.2.11-p
ackage-config-with-root.json.drv
error: Cannot build '/nix/store/qqmc7jf5m0j95wwszn0qb7rjgr92gbbn-dart-frog-cli-1.2.
11.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/0a3swm3mbjg98dcn8fqxgxajk6kkiqfp-dart-frog-cli-1.2.11-pubcache
         /nix/store/4x54mdsf3sqszj8zmr0qqcf6p2690ddi-dart-frog-cli-1.2.11

It’s worth noting that the Dart Frog CLI package is within a Dart monorepo, so the pubspec.yaml isn’t at the root of the source tree. I tried addressing that with the packageRoot attribute but it’s not working.

I’ve also tried making a Nix package for the serverpod CLI, which is also a package within a monorepo, and I had the same result.

I created the following self-contained Nix file to help reproduce the issue: WIP Dart Frog CLI Nix package · GitHub

Thank you, in advance :slight_smile:

I don’t really know much about dart-specific packaging (and don’t really feel like digging into the builder source code for it), but the general approach for monorepos in any language is to set sourceRoot:

  sourceRoot = "${src.name}/packages/dart_frog_cli";

You probably can remove the packageRoot as well, with this change.

1 Like

I’d hug you if I could! Thank you so much. That fixed my problem.

1 Like