links-lang / links

Links: Linking Theory to Practice for the Web
http://www.links-lang.org
Other
318 stars 42 forks source link

"opam install links" doesn't produce linx executable in Ocaml 5.0.0 #1176

Closed DestyNova closed 10 months ago

DestyNova commented 1 year ago

Hello, I followed the install instructions with opam 2.1.4 and Ocaml 5.0.0.

I ran this command:

$ opam install links links-sqlite3

The following actions will be performed:
  ∗ install links         0.9.7
  ∗ install links-sqlite3 0.9.7
===== ∗ 2 =====

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
⬇ retrieved links.0.9.7  (cached)
⬇ retrieved links-sqlite3.0.9.7  (cached)
∗ installed links.0.9.7
∗ installed links-sqlite3.0.9.7
Done.

This completed without error and installed links-sqlite3 in $OPAM_SWITCH_PREFIX/lib. However, it didn't add a linx executable to $OPAM_SWITCH_PREFIX/bin. When I check the installed package files, there's no output:

❯ opam show links -f installed-files

❯ opam show links-sqlite3 -f installed-files
/home/omf/.opam/5.0.0/doc/links-sqlite3
/home/omf/.opam/5.0.0/doc/links-sqlite3/CHANGES.md
/home/omf/.opam/5.0.0/doc/links-sqlite3/LICENSE
/home/omf/.opam/5.0.0/doc/links-sqlite3/README.md
/home/omf/.opam/5.0.0/lib/links-sqlite3
/home/omf/.opam/5.0.0/lib/links-sqlite3/META
/home/omf/.opam/5.0.0/lib/links-sqlite3/dune-package
/home/omf/.opam/5.0.0/lib/links-sqlite3/opam
/home/omf/.opam/5.0.0/share/links-sqlite3
/home/omf/.opam/5.0.0/share/links-sqlite3/links_sqlite3_dependencies.json

However, under Ocaml 4.14.1, linx is produced and seems to work. There seems to be some breaking change in 5.0.0 whereby linx installation silently goes wrong.

jamescheney commented 1 year ago

Thanks. There should be lots of other files for the links package installed by opam besides executables, such as examples and library files. So something is clearly wrong.

The code/configuration that does this is in the dune/dune-project files and there is nothing version-specific in these that I can see. So it may be this is a bug in dune and/or ocaml 5.

jamescheney commented 1 year ago

We just ran into this exact issue ourselves. Sorry for the long delay in looking into this. The problem is that changes were made to make Links compatible with OCaml 5.0 but version 0.9.7 predated these changes, and we did not constrain the opam metadata for older versions o flinks to require Ocaml < 5.0 (and we should). The next release will incorporate these changes, but for the moment all you can do if you want ot run links using OPAM is downgrade to OCaml 4.14.1 and reinstall. You can also check out the repository and build against ocaml 5.0 manually.

We aren't sure why the install silent;y fails/thinks it succeeded - if you use --verbose you can see that the build is failing due to a referene to a function library that went away between OCaml 4.14.1 and 5.0.

DestyNova commented 1 year ago

Thanks @jamescheney -- on a side note, do you have any plans to experiment with a WebAssembly backend rather than JS? In my brief tests the JS output was really big, like 5 MB, so I was thinking WebAssembly could help reduce load time (esp. on mobile devices). (*I say this without knowing almost anything about it.)

jamescheney commented 1 year ago

Not me personally, but I think this is on @dhil and/or @slindley's todo list. The javascript code generation is also pretty naive - currently little is done to pare down to just the library functions that a given program actually needs/uses, for example.

DestyNova commented 1 year ago

currently little is done to pare down to just the library functions that a given program actually needs/uses, for example.

Ah, makes sense. Maybe we could implement some tree shaking later and get some good results.

jamescheney commented 1 year ago

Indeed this is a longstanding issue #235

dhil commented 10 months ago

I've opened the PR on ocaml/opam-repository#24332 to address the silent installation failure issue on OCaml 5. Note that once merged, it will be impossible to install Links from OPAM with OCaml 5. To rectify this situation I will do a separate release which will be compatible with OCaml 5.

dhil commented 10 months ago

The PR has been merged. I will consider this issue fixed.