Skip to content

Throw a clear error when stack.yaml / stack.yaml.lock path is missing#73

Merged
cdepillabout merged 1 commit into
cdepillabout:mainfrom
verifiedtm:clear-error-missing-stack-yaml
Jun 30, 2026
Merged

Throw a clear error when stack.yaml / stack.yaml.lock path is missing#73
cdepillabout merged 1 commit into
cdepillabout:mainfrom
verifiedtm:clear-error-missing-stack-yaml

Conversation

@verifiedtm

Copy link
Copy Markdown
Contributor

Summary

When the stackYaml or stackYamlLock path passed to stacklock2nix doesn't exist, Nix currently raises a bare error: path '...' does not exist from deep inside the YAML-reading IFD (read-yaml.nix), with no hint at the cause. This commonly happens when stacklock2nix is evaluated without the full repository present — e.g. a Docker build that copies only a subset of the source tree.

This guards both paths with builtins.pathExists and throws an actionable message naming the likely cause. When the paths exist they're returned unchanged, so there is no behavior change for normal builds. The check is lazy — it fires at the same point the bare error did (when the stack files are first forced), not at call time.

Test plan

  • nix-instantiate --parse of the edited file passes.
  • With stack.yaml present, evaluating my-example-haskell-stacklock proceeds into the YAML IFD as before (no new error).
  • With a non-existent stackYaml, forcing the package set throws the new stacklock2nix: ... not found ... message instead of the bare path error.

🤖 Generated with Claude Code

Guard the `stackYaml` and `stackYamlLock` paths with `builtins.pathExists`
so that a missing file produces an actionable message naming the likely
cause, instead of a bare `error: path '...' does not exist` from deep
inside the YAML-reading IFD. When the paths exist they are returned
unchanged, so there is no behavior change for normal builds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cdepillabout

Copy link
Copy Markdown
Owner

This LGTM! Thanks

@cdepillabout cdepillabout merged commit 5507971 into cdepillabout:main Jun 30, 2026
2 checks passed
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