0

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?

Eleanor Holley
  • 691
  • 1
  • 7
  • 27
  • Editing a question just to *remove* the semantic formatting is bad, actually. It is helpful to people searching for answers to have keywords like "package an executable" and "File Not Found" in headings. If it doesn't suit your personal preference to use correct markdown, just don't use a platform that supports markdown. – Eleanor Holley Feb 26 '23 at 13:29

1 Answers1

0

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.

Eleanor Holley
  • 691
  • 1
  • 7
  • 27