What are the builddir and outputdir and why are they generating a "File Not Found" error?

45 Views Asked by At

The Goal: package an executable "Hello, world" program in Idris2

I'm working from the docs, which gives descriptions of the package fields but sadly doesn't provide any examples.

The issue: "File Not Found" compilation errors on the builddir and outputdir

Below is a walkthrough of my directory structure and contents.

$ ls
kata.ipkg  README.md  src

$ ls src/
Index.idr

$ cat src/Index.idr 
module Index
main : IO ()
main = putStrLn "Hello, world"

$ cat kata.ipkg 
package kata
authors = "eleanorofs"
builddir = "build"
bugtracker = "https://gitlab.com/eleanorofs/idris-kata/-/issues"
executable = "src/Index.idr"
outputdir = "dist"
homepage = "https://gitlab.com/eleanorofs/idris-kata"
main = Index
maintainers = "eleanorofs"
opts = "--cg node --directive pretty"
readme = "./README.md"
sourcedir = "./src"
sourceloc = "https://gitlab.com/eleanorofs/idris-kata"
version = 0.0.1

$ idris2 --build kata.ipkg
1/1: Building Index (./src/Index.idr)
Uncaught error: File error (dist/src/Index.idr): File Not Found

When I delete the outputdir line, it gives me the same error, but on the builddir (build/exec/src/Index.idr instead.

Questions

This makes me think I've misunderstood something pretty fundamental about how this compiler is supposed to work.

  1. Idris itself maintains the contents of build/ and dist/, right? So there's nothing I need to do to those directories, right?

  2. If so, why does it succeed in building Index.idr but then thow an error trying to find the files that I would have expected it to generate itself?

1

There are 1 best solutions below

0
On

I sort of fixed it, but I can't fully explain it.

My first error was misunderstanding the executable field. Above, I have

executable = "src/Index.idr"

But what was needed was to describe the executable output file. In my case, for node compilation, that's

executable = "index.js"

But that didn't fully solve the issue. The other necessary step was to delete the builddir and outputdir lines.

I don't know exactly why that is. Are those properties incompatible with executable or was I supplying wrong values?

I am leaving this question open to a better answer than mine because I'm still mildly curious and because anyone searching for answers about builddir and outputdir generally would be disappointed by this answer.