Skip to content

fix gemspec directive support (closes #2)#4

Open
nz wants to merge 2 commits into
nz/pipeline-refactor-and-docsfrom
nz/gemspec-directive-fix
Open

fix gemspec directive support (closes #2)#4
nz wants to merge 2 commits into
nz/pipeline-refactor-and-docsfrom
nz/gemspec-directive-fix

Conversation

@nz

@nz nz commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #2 — the group-detection IFD sandbox previously copied only Gemfile and Gemfile.lock, so any Gemfile using the gemspec directive (i.e. every gem generated by bundle gem) aborted with Bundler::InvalidOption: There are no gemspecs at … before any gems could resolve.

  • New gemspec and extraFiles params on gemfileEnv (mirrors bundlerEnv's extraConfigPaths). extraFiles is an attrset keyed by destination path so require_relative targets land where the gemspec expects them.
  • Nix-side detection of the gemspec directive raises an actionable error with a copy-pasteable fix, thrown before Bundler is ever invoked. Bypassed when the caller supplies gemGroups (which already skips the IFD).
  • New test/integration/gemspec-directive/ fixture: minimal bundle gem-shaped layout with foo.gemspec, lib/foo/version.rb, and rake as a runtime dep. Wired into flake.checks as integration-gemspec-directive.
  • Readme adds a Common Errors entry for the new error message.

Scope note

Bumps nixpkgs 24.11 to 26.05 to pick up bundler 2.6, whose bundle lock --add-checksums is required to author the fixture lockfile without hand-writing sha256s. Ruby moves from 3.3 to 3.4 as a side effect; existing checks pass unchanged. I guess if anyone has bugs on older nixpkgs/rubies open an issue and we can target that in a test matrix.

Base

Stacked on top of #3 (nz/pipeline-refactor-and-docs) since it depends on the newer parse-gemfile-and-lockfile.nix and the gemGroups escape hatch referenced in the error message.

Test plan

  • nix flake check passes on aarch64-darwin (adds integration-gemspec-directive on top of the existing checks)
  • nixfmt --check clean
  • Without gemspec, gemfileEnv throws the new actionable error (verified against the fixture)
  • With gemspec + extraFiles, the environment builds and rake loads under Ruby (validate.rb)
  • gemGroups escape hatch still bypasses the IFD (no gemspec required)
  • Verify on Linux systems via CI

@nz
nz force-pushed the nz/gemspec-directive-fix branch from ff7fd42 to 475b36f Compare July 14, 2026 17:14
@nz nz mentioned this pull request Jul 14, 2026
3 tasks
@nz
nz force-pushed the nz/pipeline-refactor-and-docs branch from a5f4e7b to 13ebc91 Compare July 14, 2026 17:26
@nz
nz force-pushed the nz/gemspec-directive-fix branch from 475b36f to e3cda70 Compare July 14, 2026 17:26
Gemfiles from the default `bundle gem` layout use the `gemspec` directive,
which makes Bundler glob for `*.gemspec` in the working directory at
Gemfile eval time. The group-detection IFD previously copied only Gemfile
and Gemfile.lock into its sandbox, so Bundler aborted with
`Bundler::InvalidOption: There are no gemspecs at ...` before any gems
could be resolved. This effectively broke gemfileEnv for every
gem-under-development.

Adds `gemspec` and `extraFiles` params to gemfileEnv, mirroring
bundlerEnv's `extraConfigPaths`. `extraFiles` is an attrset keyed by
destination path so files land where the gemspec's require_relative
calls expect them.

Detects the `gemspec` directive in Nix and throws an actionable error
(with a copy-pasteable snippet) when it appears without a matching
`gemspec` param, so users don't have to decipher a Bundler backtrace.

Bumps nixpkgs 24.11 -> 26.05 to pick up bundler >= 2.6, which is what
writes CHECKSUMS via `bundle lock --add-checksums`; the fixture lockfile
would otherwise need hand-written sha256s. Ruby moves 3.3 -> 3.4 as a
side effect; existing checks pass unchanged.

Fixture at test/integration/gemspec-directive/ exercises the full path:
a minimal `bundle gem`-style layout with foo.gemspec + lib/foo/version.rb
and rake as a runtime dep. `integration-gemspec-directive` wires it into
`nix flake check`.
@nz
nz force-pushed the nz/gemspec-directive-fix branch from e3cda70 to 10f5209 Compare July 14, 2026 17:47
The canonical `bundle gem` gemspec computes spec.files via
IO.popen(%w[git ls-files -z]). The group-inference sandbox had only
ruby and bundler on PATH, so that popen raised Errno::ENOENT and gemspec
evaluation aborted — defeating the gemspec-directive support this branch
adds. Add git to the sandbox buildInputs so the standard gemspec
evaluates and degrades to an empty file list in the non-git sandbox.
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.

2 participants