Skip to content

scripts/build fails: dist/ output directory not created before pslua writes to it #1

@Unisay

Description

@Unisay

Summary

A fresh nix develop -c ./scripts/build fails immediately with:

Building...
Compiling modules:
pslua: /.../purescript-lua-assert/dist/Test_Assert.lua: withFile: does not exist (No such file or directory)

The build cannot produce its output because the dist/ output directory does not exist on a clean checkout, and nothing in the build creates it before pslua tries to write into it.

Root cause

The pslua invocation for this package lives in the backend field of spago.dhall, which spago build runs after compiling CoreFn:

, backend =
    ''
    pslua \
    --foreign-path . \
    --ps-output output \
    --lua-output-file dist/Test_Assert.lua \
    --entry Test.Assert
    ''

pslua opens the --lua-output-file target with withFile path WriteMode (see exe/Main.hs in Unisay/purescript-lua). WriteMode creates the file but not any missing parent directories. So writing dist/Test_Assert.lua requires dist/ to already exist.

On a clean checkout it does not:

  • The repo's root .gitignore contains /dist/, so the directory is never committed.
  • scripts/build only runs spago build and never creates dist/ first.

Result: withFile: does not exist.

Why it works in sibling forks but not here

The other Lua forks (e.g. purescript-lua-prelude, purescript-lua-strings, purescript-lua-arrays) avoid this in two ways:

  1. They drive pslua directly from scripts/build rather than from the spago.dhall backend field.
  2. They commit a dist/.gitignore (containing *.lua) and do not ignore /dist/ at the repo root, so dist/ exists on a fresh checkout while the generated .lua files stay untracked.

purescript-lua-assert does neither: its root .gitignore ignores all of /dist/, there is no committed dist/.gitignore, and the pslua call sits in spago.dhall. So nothing guarantees dist/ exists at build time.

Impact

./scripts/build is broken from a clean clone for everyone — CI and any new contributor. There is no workaround other than manually mkdir dist first. The package cannot be built by following its own build script.

How it was found

Running the documented build command on a freshly-reset checkout:

git checkout master && git clean -fdx   # fresh state, no dist/
nix develop -c ./scripts/build
# -> pslua: .../dist/Test_Assert.lua: withFile: does not exist
echo $?   # 1

Suggested fix

Minimal and self-contained: have scripts/build create the output directory before building, e.g. mkdir -p dist ahead of spago build. This matches the intent of the sibling forks (guarantee dist/ exists) without restructuring the build.

Note: pslua not creating the parent directory of --lua-output-file is a latent rough edge worth tracking separately upstream in Unisay/purescript-lua; this issue tracks the package-side fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions