ahrefs / opam-check-npm-deps

An opam plugin that checks the opam switch to gather npm packages in depexts to check against installed packages in node_modules.
MIT License
3 stars 0 forks source link

Installation errors with opam #11

Open bentxt opened 2 weeks ago

bentxt commented 2 weeks ago

Hi I try to install this package on macos and I get the following errors:

opam install opam-check-npm-deps

> opam install opam-check-npm-deps
The following actions will be performed:
  βˆ— install opam-solver         2.1.6 [required by opam-client]
  βˆ— install opam-client         2.1.6 [required by opam-check-npm-deps]
  βˆ— install opam-check-npm-deps 1.0.0
===== βˆ— 3 =====
Do you want to continue? [Y/n] Y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
Processing  3/9:
⬇ retrieved opam-check-npm-deps.1.0.0  (cached)
⬇ retrieved opam-solver.2.1.6  (cached)
⬇ retrieved opam-client.2.1.6  (cached)
[ERROR] The compilation of opam-solver.2.1.6 failed at "dune build -p opam-solver -j 15".

#=== ERROR while compiling opam-solver.2.1.6 ==================================#
# context     2.1.6 | macos/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#d94dfabfa84a67443fe03586e912f15966b28089
# path        ~/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p opam-solver -j 15
# exit-code   1
# env-file    ~/.opam/log/opam-solver-78085-a5c803.env
# output-file ~/.opam/log/opam-solver-78085-a5c803.out
### output ###
# Error: posix_spawn(): Permission denied
# -> required by _build/default/src/solver/opamDoseCompat.ml.6
# -> required by _build/default/src/solver/opamDoseCompat.ml
# -> required by _build/install/default/lib/opam-solver/opamDoseCompat.ml
# -> required by _build/default/opam-solver.install
# -> required by alias install
# (cd _build/default && /Users/ben/.opam/5.1.1/bin/ocamlc.opt -w -40 -w +a-4-40-42-44-48 -safe-string -w -67 -g -bin-annot -I src/solver/.opam_solver.objs/byte -I /Users/ben/.opam/5.1.1/lib/cudf -I /Users/ben/.opam/5.1.1/lib/dose3/algo -I /Users/ben/.opam/5.1.1/lib/dose3/common -I /Users/ben/.opam/5.1.1/lib/extlib -I /Users/ben/.opam/5.1.1/lib/mccs -I /Users/ben/.opam/5.1.1/lib/mccs/glpk/intern[...]
# File "src/solver/opamCudfSolverSig.ml", line 1:
# Warning 70 [missing-mli]: Cannot find interface file.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build opam-solver 2.1.6
└─
╢─ No changes have been performed

sudo opam install opam-check-npm-deps


[I] ben@moonraker ~/s/m/melange-opam-template (main) [31]> sudo opam install opam-check-npm-deps
Password:
[WARNING] Running as root is not recommended
The following actions will be performed:
  βˆ— install opam-solver         2.1.6 [required by opam-client]
  βˆ— install opam-client         2.1.6 [required by opam-check-npm-deps]
  βˆ— install opam-check-npm-deps 1.0.0
===== βˆ— 3 =====
Do you want to continue? [Y/n] y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved opam-check-npm-deps.1.0.0  (cached)
⬇ retrieved opam-solver.2.1.6  (cached)
⬇ retrieved opam-client.2.1.6  (cached)
[ERROR] The compilation of opam-solver.2.1.6 failed at "./configure --disable-checks --prefix /Users/ben/.opam/5.1.1".

#=== ERROR while compiling opam-solver.2.1.6 ==================================#
# context     2.1.6 | macos/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#d94dfabfa84a67443fe03586e912f15966b28089
# path        ~/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./configure --disable-checks --prefix /Users/ben/.opam/5.1.1
# exit-code   77
# env-file    ~/.opam/log/opam-solver-79416-459510.env
# output-file ~/.opam/log/opam-solver-79416-459510.out
### output ###
# [...]
# checking for gawk... no
# checking for mawk... no
# checking for nawk... no
# checking for awk... awk
# checking for compiler type... cc
# checking for compiler architecture... amd64
# checking for compiler system... macosx
# checking for cc... cc -O2 -fno-strict-aliasing -fwrapv -pthread    -D_FILE_OFFSET_BITS=64
# checking whether the C compiler works... no
# configure: error: in `/Users/ben/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6':
# configure: error: C compiler cannot create executables
# See `config.log' for more details
jchavarri commented 2 weeks ago

I am not sure why this error is happening, it's in opam-solver which is an indirect dependency of opam-check-npm-deps.

Could you try running opam update and then opam install opam-check-npm-deps please?

jchavarri commented 2 weeks ago

The latest version of opam-solver is 2.2.1 but the logs show that 2.1.6 is trying to be installed.

bentxt commented 2 weeks ago

Just on a short note, it unfortunately didnt work and it seems like the same error

I could however opam install opam-solver

Could you try running opam update and then opam install opam-check-npm-deps please?

log for update and install:


ben@moonraker ~ [31]> opam update

<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><>  🐫
[default] no changes from https://opam.ocaml.org
[I] ben@moonraker ~> opam install opam-check-npm-deps
The following actions will be performed:
  βˆ— install opam-solver         2.1.6 [required by opam-client]
  βˆ— install opam-client         2.1.6 [required by opam-check-npm-deps]
  βˆ— install opam-check-npm-deps 1.0.0
===== βˆ— 3 =====
Do you want to continue? [Y/n] Y

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved opam-check-npm-deps.1.0.0  (cached)
⬇ retrieved opam-solver.2.1.6  (cached)
⬇ retrieved opam-client.2.1.6  (cached)
[ERROR] The compilation of opam-solver.2.1.6 failed at "dune build -p opam-solver -j 15".

#=== ERROR while compiling opam-solver.2.1.6 ==================================#
# context     2.1.6 | macos/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#a10f3c585f748161ae41b76e06b161b528cb9105
# path        ~/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p opam-solver -j 15
# exit-code   1
# env-file    ~/.opam/log/opam-solver-32189-46051c.env
# output-file ~/.opam/log/opam-solver-32189-46051c.out
### output ###
# Error: posix_spawn(): Permission denied
# -> required by _build/default/src/solver/opamDoseCompat.ml.6
# -> required by _build/default/src/solver/opamDoseCompat.ml
# -> required by _build/install/default/lib/opam-solver/opamDoseCompat.ml
# -> required by _build/default/opam-solver.install
# -> required by alias install
# (cd _build/default && /Users/ben/.opam/5.1.1/bin/ocamlc.opt -w -40 -w +a-4-40-42-44-48 -safe-string -w -67 -g -bin-annot -I src/solver/.opam_solver.objs/byte -I /Users/ben/.opam/5.1.1/lib/0install-solver -I /Users/ben/.opam/5.1.1/lib/cudf -I /Users/ben/.opam/5.1.1/lib/dose3/algo -I /Users/ben/.opam/5.1.1/lib/dose3/common -I /Users/ben/.opam/5.1.1/lib/extlib -I /Users/ben/.opam/5.1.1/lib/mccs [...]
# File "src/solver/opamCudfSolverSig.ml", line 1:
# Warning 70 [missing-mli]: Cannot find interface file.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build opam-solver 2.1.6
└─
╢─ No changes have been performed
jchavarri commented 2 weeks ago

Could you confirm which terminal emulator you are running? Also, if you could run opam config report and share the output please?

bentxt commented 2 weeks ago

Could you confirm which terminal emulator you are running?

 ~> echo $TERM_PROGRAM
iTerm.app
 ~> echo $TERM
xterm-256color

Also, if you could run opam config report and share the output please?

opam config report
# opam config report
# opam-version         2.1.6
# self-upgrade         no
# system               arch=x86_64 os=macos os-distribution=homebrew os-version=14.6.1
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 15
# repositories         1 (http) (default repo at a10f3c585f748161ae41b76e06b161b528cb9105)
# pinned               0
# current-switch       5.1.1
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /Users/ben/.opam/5.1.1/lib/ocaml/stublibs:/Users/ben/.opam/5.1.1/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.1.1
bentxt commented 2 weeks ago

Maybe this is also useful

which ocamlc /Users/ben/.opam/5.1.1/bin/ocamlc

-> /Users/ben/.opam/5.1.1/bin/ocamlc -config
version: 5.1.1
standard_library_default: /Users/ben/.opam/5.1.1/lib/ocaml
standard_library: /Users/ben/.opam/5.1.1/lib/ocaml
ccomp_type: cc
c_compiler: cc
ocamlc_cflags: -O2 -fno-strict-aliasing -fwrapv -pthread  
ocamlc_cppflags:  -D_FILE_OFFSET_BITS=64 
ocamlopt_cflags: -O2 -fno-strict-aliasing -fwrapv -pthread  
ocamlopt_cppflags:  -D_FILE_OFFSET_BITS=64 
bytecomp_c_compiler: cc -O2 -fno-strict-aliasing -fwrapv -pthread    -D_FILE_OFFSET_BITS=64 
native_c_compiler: cc -O2 -fno-strict-aliasing -fwrapv -pthread    -D_FILE_OFFSET_BITS=64 
bytecomp_c_libraries: -L/usr/local/opt/zstd/lib -lzstd    -lpthread
native_c_libraries:    -lpthread
native_pack_linker: ld -r -o 
native_compiler: true
architecture: amd64
model: default
int_size: 63
word_size: 64
system: macosx
asm: cc -c -Wno-trigraphs
asm_cfi_supported: true
with_frame_pointers: false
ext_exe: 
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true
host: x86_64-apple-darwin23.6.0
target: x86_64-apple-darwin23.6.0
flambda: false
safe_string: true
default_safe_string: true
flat_float_array: true
function_sections: false
afl_instrument: false
windows_unicode: false
supports_shared_libraries: true
native_dynlink: true
naked_pointers: false
exec_magic_number: Caml1999X033
cmi_magic_number: Caml1999I033
cmo_magic_number: Caml1999O033
cma_magic_number: Caml1999A033
cmx_magic_number: Caml1999Y033
cmxa_magic_number: Caml1999Z033
ast_impl_magic_number: Caml1999M033
ast_intf_magic_number: Caml1999N033
cmxs_magic_number: Caml1999D033
cmt_magic_number: Caml1999T033
linear_magic_number: Caml1999L033
bentxt commented 2 weeks ago

I don't know if you saw that, but what I don't understand is that according the error message the installations seems to fail where it wants to install 'opam-solver', but opam install opam-solver runs fine ...

The following actions failed
β”‚ Ξ» build opam-solver 2.1.6
bentxt commented 2 weeks ago

... hold on, the previous statement was not entirely true

actually opam install opam-solver.2.1.6 doesn't work and fails exactly with the same error message

bentxt commented 2 weeks ago

what I find also a bit strange, at the end of the error message, there is this statement:

...
# File "src/solver/opamCudfSolverSig.ml", line 1:
# Warning 70 [missing-mli]: Cannot find interface file.

but this file opamCudfSolverSig.ml is here:

 head -15 /Users/ben/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6/src/solver/opamCudfSolverSig.ml
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2017-2018 OCamlPro                                        *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

type criteria_def = {
  crit_default: string;
  crit_upgrade: string;
  crit_fixup: string;
  crit_best_effort_prefix: string option;

Entire error message:

opam install opam-solver.2.1.6
The following actions will be performed:
  βˆ— install opam-solver 2.1.6

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved opam-solver.2.1.6  (cached)
[ERROR] The compilation of opam-solver.2.1.6 failed at "dune build -p opam-solver -j 15".

#=== ERROR while compiling opam-solver.2.1.6 ==================================#
# context     2.1.6 | macos/x86_64 | ocaml-base-compiler.5.1.1 | https://opam.ocaml.org#a10f3c585f748161ae41b76e06b161b528cb9105
# path        ~/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p opam-solver -j 15
# exit-code   1
# env-file    ~/.opam/log/opam-solver-57810-5c081d.env
# output-file ~/.opam/log/opam-solver-57810-5c081d.out
### output ###
# Error: posix_spawn(): Permission denied
# -> required by _build/default/src/solver/opamDoseCompat.ml.6
# -> required by _build/default/src/solver/opamDoseCompat.ml
# -> required by _build/install/default/lib/opam-solver/opamDoseCompat.ml
# -> required by _build/default/opam-solver.install
# -> required by alias install
# (cd _build/default && /Users/ben/.opam/5.1.1/bin/ocamlc.opt -w -40 -w +a-4-40-42-44-48 -safe-string -w -67 -g -bin-annot -I src/solver/.opam_solver.objs/byte -I /Users/ben/.opam/5.1.1/lib/0install-solver -I /Users/ben/.opam/5.1.1/lib/cudf -I /Users/ben/.opam/5.1.1/lib/dose3/algo -I /Users/ben/.opam/5.1.1/lib/dose3/common -I /Users/ben/.opam/5.1.1/lib/extlib -I /Users/ben/.opam/5.1.1/lib/mccs [...]
# File "src/solver/opamCudfSolverSig.ml", line 1:
# Warning 70 [missing-mli]: Cannot find interface file.
bentxt commented 2 weeks ago

what I find also a bit strange, at the end of the error message, there is this statement:


...
# File "src/solver/opamCudfSolverSig.ml", line 1:
# Warning 70 [missing-mli]: Cannot find interface file.
..
but this file opamCudfSolverSig.ml is here:

Sorry, this statement was also wrong, it is the mli file that is needed and that is indeed missing

bentxt commented 2 weeks ago

I have tracked down the part of the installation that fails

The command below is looking for an mli file 'opamCudfSolverSig.mli' which is not available here is how the sources of opam-solver dir looks:

ls /Users/ben/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6/src/solver
dune                          opamBuiltin0install.mli   opamBuiltinZ3.ml.real  opamCudfSolver.mli    opamSolver.mli
opamActionGraph.ml            opamBuiltinMccs.ml.dummy  opamBuiltinZ3.mli      opamCudfSolverSig.ml  opamSolverConfig.ml
opamActionGraph.mli           opamBuiltinMccs.ml.real   opamCudf.ml            opamDoseCompat.ml.5   opamSolverConfig.mli
opamBuiltin0install.ml.dummy  opamBuiltinMccs.mli       opamCudf.mli           opamDoseCompat.mli.5
opamBuiltin0install.ml.real   opamBuiltinZ3.ml.dummy    opamCudfSolver.ml      opamSolver.ml

Failing command

cd _build/default && /Users/ben/.opam/5.1.1/bin/ocamlc.opt -w -40 -w +a-4-40-42-44-48 -safe-string -w -67 -g -bin-annot -I src/solver/.opam_solver.objs/byte -I /Users/ben/.opam/5.1.1/lib/0install-solver -I /Users/ben/.opam/5.1.1/lib/cudf -I /Users/ben/.opam/5.1.1/lib/dose3/algo -I /Users/ben/.opam/5.1.1/lib/dose3/common -I /Users/ben/.opam/5.1.1/lib/extlib -I /Users/ben/.opam/5.1.1/lib/mccs -I /Users/ben/.opam/5.1.1/lib/mccs/glpk/internal -I /Users/ben/.opam/5.1.1/lib/ocaml/unix -I /Users/ben/.opam/5.1.1/lib/ocamlgraph -I /Users/ben/.opam/5.1.1/lib/opam-0install-cudf -I /Users/ben/.opam/5.1.1/lib/opam-core -I /Users/ben/.opam/5.1.1/lib/opam-file-format -I /Users/ben/.opam/5.1.1/lib/opam-format -I /Users/ben/.opam/5.1.1/lib/re -I /Users/ben/.opam/5.1.1/lib/re/pcre -I /Users/ben/.opam/5.1.1/lib/seq -I /Users/ben/.opam/5.1.1/lib/stdlib-shims -no-alias-deps -o   src/solver/.opam_solver.objs/byte/opamCudfSolverSig.cmo -c -impl /Users/ben/.opam/5.1.1/.opam-switch/build/opam-solver.2.1.6/src/solver/opamCudfSolverSig.ml
bentxt commented 2 weeks ago

I also tried to find out more about this message:

Error: posix_spawn(): Permission denied

This error show up when I go in the root of the project and run make, where the Makefile calls dune

~/.opam/default/bin/dune build --profile=release --root .   --promote-install-files -- opam-installer.install opam.install
Error: posix_spawn(): Permission denied
-> required by _build/default/src/client/opamBase64Compat.ml.6
-> required by _build/default/src/client/opamBase64Compat.ml
-> required by
   _build/default/src/client/.opam_client.objs/native/opamBase64Compat.cmx
-> required by _build/default/src/client/opam_client.cmxa
-> required by _build/default/src/client/opamMain.exe
-> required by _build/install/default/bin/opam
-> required by _build/default/opam.install

So maybie the problems stem from dune?

bentxt commented 2 weeks ago

I think I has to do with dune, because opam-solver builds when I downgrade dune

I read somewhere that dune 3.11.1 introduced some new stuff around macos and posix_spawn(). So I downgraded dune to 3.9.1:

opam install dune.3.09.1

Then I got the following slightly absurd error message:

dune build --profile=release --root .   --promote-install-files -- opam-installer.install opam.install
Error: execve(/Users/ben/.bun/bin/echo): Permission denied

So of course I've tossed the ~/.bun stuff and voila, make worked (besides the mli warnings from above)

bentxt commented 2 weeks ago

I now also can install the rest of the packages. It seems like this is possible because I've downgraded dune:

dune --version
3.9.1

From my humble user experience, the error reporting experience was really poor, since in the initial global error report there was no clear reference to the faulty dune command.

Final successfull installation

opam install opam-solver.2.1.6
The following actions will be performed:
  βˆ— install opam-solver 2.1.6

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved opam-solver.2.1.6  (cached)
βˆ— installed opam-solver.2.1.6
Done.
[I] ben@moonraker ~/.o/5/.o/b/opam-solver.2.1.6> opam install opam-check-npm-deps
The following actions will be performed:
  βˆ— install opam-client         2.1.6 [required by opam-check-npm-deps]
  βˆ— install opam-check-npm-deps 1.0.0

I think the config is the same:

opam config report
# opam config report
# opam-version         2.1.6
# self-upgrade         no
# system               arch=x86_64 os=macos os-distribution=homebrew os-version=14.6.1
# solver               builtin-mccs+glpk
# install-criteria     -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria     -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs                 15
# repositories         1 (http) (default repo at a10f3c585f748161ae41b76e06b161b528cb9105)
# pinned               0
# current-switch       5.1.1
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /Users/ben/.opam/5.1.1/lib/ocaml/stublibs:/Users/ben/.opam/5.1.1/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       5.1.1
kit-ty-kate commented 1 week ago

Have you tried to upgrade dune again now that ~/.bun/bin is not in your PATH anymore? Having a faulty echo binary in your PATH above the one required by POSIX would indeed explain your issue