tmattio / spin

OCaml project generator.
ISC License
297 stars 15 forks source link

Distribute on NPM and Homebrew #78

Closed tmattio closed 4 years ago

tmattio commented 4 years ago

Spin 0.6.0 is complete, but I encountered several issues when trying to distribute it. As of now, it is released on Opam, but not on NPM and Homebrew.

Unfortunately, I have to work on something else and won't have a lot of time to solve these issues in the coming weeks, so I'm documenting them here and will try to address them when I have time.

CI/CD of templates

Running make test-template will run integration tests on all combinations of the official templates. This works well locally, but when run on Github Actions, it throws the following error:

error: build failed with exit code: 1
  build log:
    # esy-build-package: building: ocaml@4.9.1000
    # esy-build-package: pwd: /home/runner/.esy/3/b/ocaml-4.9.1000-ffe51dac

  building ocaml@4.9.1000

My initial guess was that there was some issue because the test were run concurrently, but I tried running only one test and it reproduces. I've also tried with different version of OCaml and Esy, but can't seem to solve the issue.

Camomile depends on local files

To improve the prompt experience, Spin 0.6.0 uses Inquire, which is built on top of Lambda-Term, which uses Camomile. Unfortunately, Camomile depends on some files to be present in user's file system. This is fine when distributing with Opam, because dune will install these files, but binaries distributed on NPM or Homebrew throw the following error:

Fatal error: exception Not_found
Raised at file "Camomile/internal/database.ml", line 50, characters 52-67
Called from file "Camomile/internal/unidata.ml" (inlined), line 187, characters 4-48
Called from file "Camomile/public/uCharInfo.ml", line 376, characters 16-46
Called from file "src/zed_utf8.ml", line 816, characters 13-53

I've been trying to package the dependency files with the binary, but with no luck. I see three solutions:

despairblue commented 4 years ago

The using a script install method is currently broken too:

  1. the link is wrong since the script directory changed names (scripts -> script)
  2. the binary in the zip file is now called main.exe
  3. the camomile thing you listed above

Regarding 3., would it be possible to use ocaml-crunch to bake the file camomile needs into the binary?

tmattio commented 4 years ago

Hey @despairblue!

Thanks for listing the issues with the script installation. I've fixed the first two.

Regarding the Camomille issue, I opened an issue on Lambda-Term and there was already some work in progress to remove the dependency on Camomille. I'll wait a bit to see if a new version of Lambda-Term is released in the next week or so, and I'll vendor the WIP repositories if not.

tmattio commented 4 years ago

I've vendored a Camomille-free version of Inquire. This means that I will be able to deploy the next release on NPM. I want to finish two templates (spa and web) before I release, but once they are merged, we'll finally have Spin 0.6.X on NPM (and Homebrew)!