hax icon indicating copy to clipboard operation
hax copied to clipboard

Missing OPAM flag on installation instructions when working with several switches

Open clementblaudeau opened this issue 7 months ago • 5 comments

When setting up hax (using ./setup) on a system that already has opam switches (with other ocaml versions), the installation of topkg fails. This comes from the usage of an old environment variable OCAMLTOP_INCLUDE_PATH that is not properly reset between opam switches until ocaml 5.3.

Error message
[ERROR] The compilation of topkg.1.0.8 failed at "ocaml pkg/pkg.ml build --pkg-name topkg --dev-pkg
        false".

#=== ERROR while compiling topkg.1.0.8 ========================================#
# context     2.3.0 | linux/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#58c7821a2ec75552933315247b1d9318a3314d66
# path        ~/.opam/hax/.opam-switch/build/topkg.1.0.8
# command     ~/.opam/opam-init/hooks/sandbox.sh build ocaml pkg/pkg.ml build --pkg-name topkg --dev-pkg false
# exit-code   125
# env-file    ~/.opam/log/topkg-310839-3e50b8.env
# output-file ~/.opam/log/topkg-310839-3e50b8.out
### output ###
# File /home/username/.opam/dev/lib/findlib/findlib.cma is not a bytecode object file.
# Exception: Compenv.Exit_with_status 125.

On my setup, doing :

env | grep OCAML

reveals the two variables OCAML_TOPLEVEL_PATH (correct path) and OCAMLTOP_INCLUDE_PATH (incorrect path from another switch). Doing :

OCAMLTOP_INCLUDE_PATH=$OCAML_TOPLEVEL_PATH; ./setup

worked for me.

Either the instructions can be updated to include this corner case, or (better) the dependency over topkg should be removed, as it is no longer actively maintained.

clementblaudeau avatar May 05 '25 13:05 clementblaudeau

Where does the dependency of topkg comes from? If we can indeed drop it that's great.

(I'm not using opam myself, so I'm not seeing those problems :S)

W95Psp avatar May 12 '25 08:05 W95Psp

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Jul 17 '25 00:07 github-actions[bot]

I recall we discussed that informally, @clementblaudeau do you recall what was the conclusion here?

W95Psp avatar Jul 17 '25 08:07 W95Psp

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Oct 16 '25 00:10 github-actions[bot]

@clementblaudeau Can you triage this?

maximebuyse avatar Oct 30 '25 12:10 maximebuyse