opam icon indicating copy to clipboard operation
opam copied to clipboard

opam depext support for macos

Open MSoegtropIMC opened this issue 3 years ago β€’ 4 comments

I wanted to switch from opam 2.0.X to opam 2.1.2, but the integrated depext still doesn't seem to support macOS:

opam install conf-pkg-config
[NOTE] External dependency handling not supported for OS family 'macos'.
       You can disable this check using 'opam option --global depext=false'
The following actions will be performed:
  βˆ— install conf-pkg-config 2

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
[ERROR] The compilation of conf-pkg-config.2 failed at "pkg-config --help".

#=== ERROR while compiling conf-pkg-config.2 ==================================#
# context     2.1.2 | macos/x86_64 | ocaml-option-flambda.1 ocaml-variants.4.13.1+options | https://opam.ocaml.org#73531078
# path        ~/.opam/__coq-platform.2022.04.1~8.16+rc1~2022.09~preview1/.opam-switch/build/conf-pkg-config.2
# command     ~/.opam/opam-init/hooks/sandbox.sh build pkg-config --help
# exit-code   71
# env-file    ~/.opam/log/conf-pkg-config-16221-c99f60.env
# output-file ~/.opam/log/conf-pkg-config-16221-c99f60.out
### output ###
# sandbox-exec: execvp() of 'pkg-config' failed: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫 
β”Œβ”€ The following actions failed
β”‚ Ξ» build conf-pkg-config 2
└─ 
╢─ No changes have been performed

I wonder what the recommendation of the opam team for multi platform projects is. Should I stick with opam 2.0.X for the time being? Am I missing something?

# opam config report
# opam-version         2.1.2 
# self-upgrade         no
# system               arch=x86_64 os=macos os-distribution=macos os-version=11.6
# 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                 1
# repositories         4 (http), 3 (local) (default repo at 73531078)
# pinned               0
# current-switch       __coq-platform.2022.04.1~8.16+rc1~2022.09~preview1
[NOTE] External dependency handling not supported for OS family 'macos'.
       You can disable this check using 'opam option --global depext=false'
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /Users/admin/.opam/__coq-platform.2022.04.1~8.16+rc1~2022.09~preview1/lib/ocaml/stublibs:/Users/admin/.opam/__coq-platform.2022.04.1~8.16+rc1~2022.09~preview1/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       4.13.1+options+flambda

MSoegtropIMC avatar Aug 11 '22 09:08 MSoegtropIMC

P.S.: the above was with a MacPorts machine. With Homebrew it appears to work.

I find this error message highly confusing. If it works in general, but there is an issue with MacPorts and/or Homebrew, the error message should state this.

MSoegtropIMC avatar Aug 11 '22 12:08 MSoegtropIMC

opam detects the "distribution" of macOS (which package manager it has) by looking for specific commands: https://github.com/ocaml/opam/blob/9b5873a0f712e5fd9f7c54a1c93972017518843a/src/state/opamSysPoll.ml#L96 As you can see here, it will detect macports if the port command is available.

How do you access macports on your installation?

kit-ty-kate avatar Aug 11 '22 13:08 kit-ty-kate

Just 'port' works - it is installed in the usual location '/opt/local/bin/port'.

But it was a fresh VM. I can't exclude that I did e.g. install MacPorts in one terminal and then opam in another terminal which I opened before installing MacPorts.

Still I find the error message highly confusing. It should probably say:

External dependency handling for OS family 'macos' requires either MacPorts or Homebrew - neither could be found

instead of

External dependency handling not supported for OS family 'macos'

MSoegtropIMC avatar Aug 11 '22 14:08 MSoegtropIMC

But it was a fresh VM. I can't exclude that I did e.g. install MacPorts in one terminal and then opam in another terminal which I opened before installing MacPorts.

ah indeed, then /opt/local/bin wouldn't be in $PATH and it wouldn't be found. Though opening a new terminal again should work (the distribution detection is dynamic)

I opened https://github.com/ocaml/opam/pull/5240 for your suggestion.

kit-ty-kate avatar Aug 11 '22 14:08 kit-ty-kate

Thanks, I think we can close this - I just got confused by the error message.

MSoegtropIMC avatar Aug 12 '22 07:08 MSoegtropIMC