Since about two weeks I am trying to compile BATSH. Unfortunately, I don’t have any experience with OCaml nor do I plan to dive into it. All I want is getting BATSH to run, but opam keeps fighting me on that and I don’t know what to do. Here is the output from my most recent try of compiling the software:
-> removed ocaml-base-compiler.4.03.0
-> installed conf-m4.1
-> installed conf-which.1
-> installed ocaml-base-compiler.4.02.2
-> installed ocaml-config.1
-> installed ocaml.4.02.2
[ERROR] The compilation of dune failed at "/home/opam/.opam/4.03.0/bin/ocaml bootstrap.ml".
-> installed base-ocamlbuild.base
-> installed ocamlbuild.0
-> installed camlp4.4.02+7
-> installed ocamlfind.1.8.1
[ERROR] The compilation of ocp-build failed at "/usr/bin/make".
-> installed base-bytes.base
-> installed herelib.112.35.00
-> installed opam-depext.1.1.3
-> installed depext.transition
-> installed ounit.2.0.8
-> installed pipebang.113.00.00
-> installed type_conv.113.00.02
[ERROR] The compilation of pa_ounit failed at "/usr/bin/make".
-> installed bin_prot.113.00.00
-> installed comparelib.113.00.00
-> installed enumerate.111.08.00
-> installed fieldslib.113.00.00
-> installed sexplib.113.00.00
-> installed pa_structural_sexp.113.00.00
-> installed pa_test.112.24.00
-> installed typerep.113.00.00
-> installed variantslib.109.15.03
#=== ERROR while compiling pa_ounit.113.00.00 =================================#
# context 2.0.5 | linux/x86_64 | ocaml-base-compiler.4.02.2 | https://opam.ocaml.org#679c0435
# path ~/.opam/4.03.0/.opam-switch/build/pa_ounit.113.00.00
# command /usr/bin/make
# exit-code 2
# env-file ~/.opam/log/pa_ounit-7-51cb9c.env
# output-file ~/.opam/log/pa_ounit-7-51cb9c.out
### output ###
# [...]
# Warning 40: Pstr_eval was selected from type Parsetree.structure_item_desc.
# It is not visible in the current scope, and will not
# be selected if the type becomes unknown.
# File "src/pa_ounit.ml", line 85, characters 8-15:
# Warning 3: deprecated: String.set
# Use Bytes.set instead.
# File "src/pa_ounit.ml", line 1:
# Error: /home/opam/.opam/4.03.0/lib/ocaml/compiler-libs/pprintast.cmx
# is not a compilation unit description.
# Command exited with code 2.
# E: Failure("Command ''/home/opam/.opam/4.03.0/bin/ocamlbuild' runtime-lib/pa_ounit_lib.cma runtime-lib/pa_ounit_lib.cmxa runtime-lib/pa_ounit_lib.a runtime-lib/pa_ounit_lib.cmxs src/pa_ounit_syntax.cma src/pa_ounit_syntax.cmxa src/pa_ounit_syntax.a src/pa_ounit_syntax.cmxs -use-ocamlfind -tag debug' terminated with error code 10")
# make: *** [Makefile:21: build] Error 1
#=== ERROR while compiling ocp-build.1.99.8-beta ==============================#
# context 2.0.5 | linux/x86_64 | ocaml-base-compiler.4.02.2 | https://opam.ocaml.org#679c0435
# path ~/.opam/4.03.0/.opam-switch/build/ocp-build.1.99.8-beta
# command /usr/bin/make
# exit-code 2
# env-file ~/.opam/log/ocp-build-7-f802f4.env
# output-file ~/.opam/log/ocp-build-7-f802f4.out
### output ###
# [...]
# gcc -Wl,-E -o ocamlrun \
# prims.o libbyterun402.a -lm -ldl -lcurses -lpthread
# echo "/usr/local/lib/ocaml/stublibs" > ld.conf
# echo "/usr/local/lib/ocaml" >> ld.conf
# make[2]: Leaving directory '/home/opam/.opam/4.03.0/.opam-switch/build/ocp-build.1.99.8-beta/boot/ocamlrun-4.02/byterun'
# ocamlc -o ocp-build.run -custom -make-runtime win32_c.c primitives.ml unix.cma -cclib -lunix -I ocamlrun-4.02/byterun -cclib -lbyterun402
# cat ocp-build.run ocp-build.boot > ocp-build
# chmod +x ocp-build
# ./ocp-build -help >/dev/null 2>&1
# make[1]: *** [Makefile:8: ocp-build] Error 2
# make[1]: Leaving directory '/home/opam/.opam/4.03.0/.opam-switch/build/ocp-build.1.99.8-beta/boot'
# make: *** [Makefile:34: boot/ocp-build] Error 2
#=== ERROR while compiling dune.1.11.4 ========================================#
# context 2.0.5 | linux/x86_64 | ocaml-base-compiler.4.02.2 | https://opam.ocaml.org#679c0435
# path ~/.opam/4.03.0/.opam-switch/build/dune.1.11.4
# command ~/.opam/4.03.0/bin/ocaml bootstrap.ml
# exit-code 2
# env-file ~/.opam/log/dune-7-62c920.env
# output-file ~/.opam/log/dune-7-62c920.out
### output ###
# cp src/ocaml-syntax-shims/pp.real.ml src/ocaml-syntax-shims/pp.ml
# cp src/ocaml-syntax-shims/shims.402.ml src/ocaml-syntax-shims/shims.ml
# /home/opam/.opam/4.03.0/bin/ocamllex.opt -q src/ocaml-syntax-shims/let_trail.mll
# /home/opam/.opam/4.03.0/bin/ocamldep.opt -modules src/ocaml-syntax-shims/let_trail.mli src/ocaml-syntax-shims/let_trail.ml src/ocaml-syntax-shims/pp.ml src/ocaml-syntax-shims/shims.ml > boot-depends.txt
# /home/opam/.opam/4.03.0/bin/ocamlopt.opt -g -w -40 -o boot-pp.exe -I +compiler-libs ocamlcommon.cmxa boot_pp.ml
# File "boot_pp.ml", line 1:
# Error: /home/opam/.opam/4.03.0/lib/ocaml/compiler-libs/location.cmx
# is not a compilation unit description.
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
+- The following actions failed
| - build dune 1.11.4
| - build ocp-build 1.99.8-beta
| - build pa_ounit 113.00.00
+-
+- The following changes have been performed (the rest was aborted)
| - downgrade ocaml 4.03.0 to 4.02.2
| - downgrade ocaml-base-compiler 4.03.0 to 4.02.2
| - recompile depext transition
| - recompile ocaml-config 1
| - recompile opam-depext 1.1.3
| - install base-bytes base
| - install base-ocamlbuild base
| - install bin_prot 113.00.00
| - install camlp4 4.02+7
| - install comparelib 113.00.00
| - install conf-m4 1
| - install conf-which 1
| - install enumerate 111.08.00
| - install fieldslib 113.00.00
| - install herelib 112.35.00
| - install ocamlbuild 0
| - install ocamlfind 1.8.1
| - install ounit 2.0.8
| - install pa_structural_sexp 113.00.00
| - install pa_test 112.24.00
| - install pipebang 113.00.00
| - install sexplib 113.00.00
| - install type_conv 113.00.02
| - install typerep 113.00.00
| - install variantslib 109.15.03
+-
# Run eval $(opam env) to update the current shell environment
The former state can be restored with:
opam switch import "/home/opam/.opam/4.03.0/.opam-switch/backup/state-20191116000244.export"
The command '/bin/sh -c /bin/sh -c "opam install --unlock-base -y batsh.0.0.6"' returned a non-zero code: 31
Depending on the compiler version, it gives me different erros. The compiler which does it best, but still fails is ocaml-base-compiler.4.02.2 where it only complains about ocp-build not being able to be compiled(?), as seen in the above error: [ERROR] The compilation of ocp-build failed at "/usr/bin/make". This is ultimately where I am stuck. If I can compile ocp-build successfully on version 4.02.2, it should run.
The errors you are showing look fairly strange; it looks like, from a switch for OCaml 4.03.0, you or opam decided to remove the compiler version 4.03.0 and install instead a 4.02 compiler; then some packages try to use tools at version 4.03.0 at they get into version-incompatibility errors.
You could try to start again from a clean environment, for example by wiping your ~/.opam (assuming there are no other OCaml programs that you care about in it), and starting again.
On my machine, opam install batsh.0.0.6 worked correctly when starting from a 4.01.0 switch. (I first tried my 4.02.3 switch but it is incompatible with the ocp-builder version required by batsh.) I think that what goes wrong is that you use only opam install batsh, instead of opam install batsh.0.0.6; opam notices that the latest version is un-buildable and tries to go with an earlier version. But for experimental software like this (versions 0.0.x), the earlier versions usually have incorrect packaging information that was fixed in later iterations, and it’s no surprise that they don’t build correctly.
I know, I studied the project just to get it run. Yet, it still does not run. That said, as long as it works, it does not matter much if it is abandoned or not, since BASH and/or BATCH won’t change significantly anytime soon. They are so old, I’d wonder if they would change anything, really. And even if that would happen, no distribution would suddenly run the absolutely newest version of BASH, for example. Therefore, it’s good as it is.
Did you manage to run BATSH successfully? If yes, how did you do that?
On my machine the batsh binary seems to work correctly – it displays a help/usage message.
What fails in your 4.01 log is that ocp-builder does not build correctly – it’s not a problem with the batsh codebase itself. I suppose that this old version of ocp-builder (batsh claims to be incompatible with more recent versions) has a bug that makes it fail on your system.
Personally I would think that trying lots of tweaks may not be the most efficient approach to get the software in a workable state for you. It could be nicer to make a change that is reasonable for the long term, so that if that change works it can be relied upon by other interested users. For example, if ocp-builder is the problem, it sounds reasonable to try to use a different build system instead – I would try with plain old make, which is going to work well even under the old version of OCaml that batsh currently requires. The batsh codebase does not look that complicated, so it shouldn’t be a lot of work – for someone that knows enough OCaml to understand what the current build system does.
Have you considered contacting the original authors of the software to ask them to make that change? (Or: to port the software on a more recent version of OCaml that has a working ocp-builder for your system.) This sounds like a good solution for many people: they would update the upstream repository with a better version, it would take them less effort than it takes you (not being familiar with OCaml), and they get to hear of people interested in their software, which is always nice.
Unfortunately, as @XVilka already implied, there does not seem to be any interest left in maintaining the project from the author’s perspective.
I believe that, but I don’t know how much I would need to study OCaml just to get this run. I don’t know if it would be worth the effort. On the other hand, I don’t know any other project that might get the job done equivalently or even better. So maybe I have no choice but to. At least I am familiar with programming overall and know some stuff, it’s just OCaml itself that is holding me back, especially since I am currently already learning 2 languages (Nim and Julia) intensely and I also need/learn/use Java since years. Adding another language to my mix does not exactly make my life easier.
Well, I will have at least a look at ocp-builder and see if I can brainstorm some ideas. Let’s see.
Did you send a direct email to the authors to check? Unless you do, I don’t think you can reasonably make a guess about what they are interested or not in doing to help people use their software. In particular, you can’t assume that people maintain in the same way if they don’t know that anyone is using their software vs. if they hear from interested users.
You are right. Though I had bad experiences with this. The last time someone contacted the author of an abandonend project, he actually archived the Github repository, without any answer or further notice. Clearly shrugging off this project entirely.
Author doen’t respond to the issues opened long time ago. So I wouldn’t expect anything to be done. Sorry for shattering any hope, but that’s how it usually works.
I know that myself as a maintainer am more likely to respond to a direct email than to a Github issue, especially if the person opening the issue does not seem to be using the project themselves. I invest work when I understand there is user demand, an issue like “hey this technology is deprectated, please stop using it” is not going to motivate me enormously.
Beside, I think that whether the project uses Camlp4 or not is sort of beside the point here. We should be able to keep using software that was written in the past using Camlp4, there is nothing about it that makes it unfit to run on modern processors, and if I remember correctly we have a maintainer willing to keep it working-as-usual in the medium term.
Being able to use it under a more recent OCaml version than 4.01 (released in September 2013; note that 4.01 still works just fine on my machine at least) would be a plus, and I think it was not the best choice of original authors to use ocp-build, a niche build system that, unless I’m mistaken, was never officially released to the public. It is fairly likely that these two aspects (supporting more recent OCaml releases, and at least supporting newer ocp-builder version) can be improved upon with fairly little work, especially if people already familiar with the codebase do it. (Migrating off Camlp4 may also be fairly easy, if the deriving plugins they use exist for the ppx versions, but again I don’t think this is the main obstacle to run the software.)
@gasche
Fully agree with you. And again, the software is mainly bound to play well with Bash and Batch. These two languages are pretty much carved into the stone anyway. So I don’t see a real need in keeping Batsh rigorously up to date.
I tried using Debian native opam1, opam2 and official base opam image from OCaml. I will upload the Dockerfiles, when I have the time to. Right now I have to go. But sure, I’ll do it. Thanks for your help, anyway.
I ended up changing the type to use Hashtbl.Poly.t, which provides a t_of_sexp implementation as documented here if I’m reading it correctly. But would like to get some second opinions on whether this the right choice regardless.