Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os-distribution #4885

Closed
diremy opened this issue Nov 3, 2021 · 4 comments · Fixed by #4892
Closed

os-distribution #4885

diremy opened this issue Nov 3, 2021 · 4 comments · Fixed by #4892
Milestone

Comments

@diremy
Copy link

diremy commented Nov 3, 2021

$ opam --version
2.1.0

opam has a global configuration variable os-distribution, but this variable seems to be ignored at least in most (if not all) cases, instead trying to guess the its value dynamically by checking which one of the two commands brew or port (in this order) is executable.

Here is my global config:

$ opam var | grep os
os                macos             # Inferred from system
os-distribution   macports          # Set through 'opam config set-global'
os-family         bsd               # Set through 'opam config set-global'
os-version        11.6              # Inferred from system

However, opam seems to bypass this configuration:

$ opam config report | grep system
# system               arch=x86_64 os=macos os-distribution=homebrew os-version=11.6

The reason is that (for some reason) I have both port and brew binaries installed.
Indeed, removing the executable rights to the brew command

$ chmod -x /usr/local/bin/brew 

fixes the problem:

$ opam config report | grep system
# system               arch=x86_64 os=macos os-distribution=macports os-version=11.6

But I consider this to be a bug since the global os-distribution variable seems to be always overriden.

As a result, opam

  • always wants to install external dependencies with brew, which I must refuse.
  • fails to install most conf-* packages even when these are correctly installed with macports.

My only solution is thus to make brew non-executable.

@kit-ty-kate kit-ty-kate transferred this issue from ocaml/opam-repository Nov 3, 2021
@rjbou rjbou added this to the 2.2.0~alpha milestone Nov 3, 2021
@rjbou rjbou added the KIND: BUG label Nov 3, 2021
@rjbou
Copy link
Collaborator

rjbou commented Nov 3, 2021

One "issue" here is that opam let you think that you changed the internal os-distribution while you just set up a new value for os-distribution variable, it have only an effect on variables handling, see this test for an example.
We should permit overriding or at least a way to set a priority instead of default ones (brew is tested first, then macports).

@diremy
Copy link
Author

diremy commented Nov 3, 2021

One "issue" here is that opam let you think that you changed the internal os-distribution while you just set up a new value for os-distribution variable, it have only an effect on variables handling.

I don't understand: os-distribution is not a system variable. It is only an opam variable. When I say that os-distribution is macports, opam could maybe check that this is meaningful, i.e. check the existence of port, but I don't understand the reason not to take my global setting into account.

(BTW, I don't understand the use of the global variable os-distribution if it is always overridden by opam at runtime.)

see this test for an example.

I don't understand what this example is there to illustrate.

We should permit overriding or at least a way to set a priority instead of default ones (brew is tested first, then macports).

Why not then use the global value of os-distribution to check what I said first, and I it is not consistent (e.g. if I said macports and port is not executable), then fall back to the other alternative---or report an error?

Didier

@kit-ty-kate
Copy link
Member

I had a try at fixing this in #4886. The code is horrible (because of a cyclic dependency I couldn’t wrap my head around) but it I’ve tested it and it seems to work. (though in your case you also need to set os-family to macports, not bsd). Feel free to give it try at your own risks ^^"

@diremy
Copy link
Author

diremy commented Nov 4, 2021

BTW, I had trouble finding out where the problem originated from.
I wanted to see the command actually executed while installing the package conf-xxx, so I used verbose and debug flags, but there was zeo trace of the execution of the command specified in the build field of the meta file. I assume that this is still logged somewhere. Could the user access the log? If so, it would help showing the path on stdout (or explain how to get it in the documentation of opam). Otherwise logging this command (and its return code) on stdout in verbose mode would be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants