dune icon indicating copy to clipboard operation
dune copied to clipboard

If dune tools install fails to install a tool it can break a user's environment

Open sroerick opened this issue 1 month ago • 4 comments

Expected Behavior

lsptools are installed

Actual Behavior

Installer fails on 'dune tools install ocamllsp, with message

File "dev-tools.locks/ocaml-lsp-server/ocaml-compiler.pkg", line 112, characters 3-76:
112 |    https://github.com/ocaml/ocaml/releases/download/5.4.0/ocaml-5.4.0.tar.gz)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: failed to extract 'download'
Reason: 'tar' failed with non-zero exit code '1' and output:
- tar: input compressed with gzip; use the -z option to decompress it.

I can no longer dune build, there seems to be no way to uninstall the tool, and the incomplete install has prevented all other progress on this repo.

Reproduction

I think this is derived from the OpenBSD version of tar? Other 'dune tools install' command fail in the same way

Specifications

  • Version of dune (output of dune --version): 3.20.2
  • Version of ocaml (output of ocamlc --version):
  • Operating system (distribution and version):
  • OpenBSD 7.8

sroerick avatar Nov 29 '25 04:11 sroerick

Thank you for the report, @sroerick, and I'm sorry you had to wait so long for a proper reply. We don't currently have support for dune package management outside of linux and MacOS, unfortunately. This is on the roadmap, however, and the limitation is an important part of why the features are stilled marked as 'experimental'. Your report will help us motivate that support, which we know to be important.

shonfeder avatar Dec 10 '25 12:12 shonfeder

No problem! Thanks. I was able to continue by deleting the .dunetools dir.

I love OpenBSD and do a lot of dev and deployment there, but will stick to linux for first class DX.

Hopefully a pretty easy fix, maybe I can contribute when I get a bit more comfortable. Thanks

sroerick avatar Dec 10 '25 19:12 sroerick

Contributions welcome :) Fortunately @Alizter seems to have a fix in the works here.

This issue falls into two parts:

  1. dune tools must have better error handling: it cannot leave user environments broken because a package fails to install (for whatever reason)
  2. We need to support tar correctly on OpenBSD. This is tracked in https://github.com/ocaml/dune/issues/10123

I will retitle this issue to reflect the general problem of (1).

shonfeder avatar Dec 11 '25 03:12 shonfeder

@sroerick Could you test out https://github.com/ocaml/dune/pull/12917

Alizter avatar Dec 11 '25 13:12 Alizter

@sroerick if you have time to test #12917 , as @Alizter proposes, you can install his branch of dune into your opam switch with

opam pin dune [email protected]:Alizter/dune.git#push-tkrvytnyslnk

Please don't feel an obligation to test this, but we would be grateful for any feedback you have time to share!

shonfeder avatar Dec 12 '25 21:12 shonfeder

I was not able to build this version of dune,

opam pin dune [email protected]:Alizter/dune.git#push-tkrvytnyslnk

failed with the following:

[ERROR] The compilation of dune.3.20.2 failed at "ocaml boot/bootstrap.ml -j 1".

#=== ERROR while compiling dune.3.20.2 ========================================#
# context     2.4.1 | openbsd/x86_64 | ocaml.5.3.0 | pinned(git+ssh://[email protected]/Alizter/dune.git#push-tkrvytnyslnk#a6eb8597553
208bb9094fe3076557a2218bbe9ca)
# path        ~/dev/ocaml/dabar2/_opam/.opam-switch/build/dune.3.20.2
# command     ~/dev/ocaml/dabar2/_opam/bin/ocaml boot/bootstrap.ml -j 1
# exit-code   2
# env-file    ~/.opam/log/dune-34010-f5f0a7.env
# output-file ~/.opam/log/dune-34010-f5f0a7.out
### output ###
# ocamlc -output-complete-exe -intf-suffix .dummy -g -o .duneboot.exe -I boot -I +unix unix.cma boot/types.ml boot/libs.ml boot/dun
eboot.ml
# ./.duneboot.exe -j 1
# cd _boot && /home/roerick/dev/ocaml/dabar2/_opam/bin/ocamlopt.opt -c -g -I +unix -I +threads lmdb_stubs.c -ccopt -I .
# vendor/ocaml-lmdb/lmdb_stubs.c:23:10: fatal error: 'alloca.h' file not found
#    23 | #include <alloca.h>
#       |          ^~~~~~~~~~
# 1 error generated.



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build dune 3.20.2
+-
- No changes have been performed

sroerick avatar Dec 20 '25 19:12 sroerick

@sroerick I recently tweaked that file so that it would compile on FreeBSD. It seems the same will have to be done for OpenBSD also. Could you try adding

|| defined(__OpenBSD__)

to https://github.com/ocaml/dune/blob/a2f36ad7df0fd54d512f1a2ca31fc933d1a7ba03/vendor/ocaml-lmdb/lmdb_stubs.c#L20

and then try compiling again?

We are vendoring lmdb in 3.21 which needs some tweaking to get compiling on the bsds.

You will need to clone my branch locally to do this and then pin to the directory.

Alizter avatar Dec 20 '25 20:12 Alizter