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

Installation of a package fails in local opam switch with dune install #6944

Closed
AllanBlanchard opened this issue Jan 27, 2023 · 3 comments
Closed

Comments

@AllanBlanchard
Copy link

When one uses directly dune install as an installation command in an opam file, installing this package in a local switch containing a dune project file does not apply the command on the right directory(?).

Steps to reproduce:

dune init project foo
dune build --root foo
echo "install: [ \"dune\" \"install\" ]" >> foo/foo.opam

mkdir test && cd test
opam switch create . 4.14.1 
eval $(opam env)
touch dune-project # makes sure that we have an ill-formed dune-project to see the error
opam pin ../foo

Result:

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ERROR] The installation of foo failed at "dune install".

#=== ERROR while installing foo.~dev ==========================================#
# context     2.0.8 | linux/x86_64 | ocaml-base-compiler.4.14.1 | pinned(file:///tmp/foo)
# path        /tmp/test/_opam/.opam-switch/build/foo.~dev
# command     ~/.opam/opam-init/hooks/sandbox.sh install dune install
# exit-code   1
# env-file    ~/.opam/log/foo-110695-e7966f.env
# output-file ~/.opam/log/foo-110695-e7966f.out
### output ###
# Entering directory '/tmp/test'
# File "dune-project", line 1, characters 0-0:
# Error: Invalid first line, expected: (lang <lang> <version>)

By adding --root . to installation command it seems to work. But I'd like to know if it is a workaround or a solution (because what is explained before is indeed not supposed to work). It has been detected with the Frama-C package:

https://git.frama-c.com/pub/frama-c/-/issues/2645

It seems that there are (related?) problems with other packages, say for example haxe:

https://git.frama-c.com/pub/frama-c/-/issues/2645#note_207676

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Jan 27, 2023

Did you meant to open this issue in dune's bugtracker instead? I'm not sure what this has to do with opam.

To me this seems like an expected behaviour of dune (even if i personally don't agree with it), aka. "dune commands by default will always look for the upper most dune project instead of the current directory. This behaviour can be changed using --root or -p".

If there was a DUNE_ROOT environment variable we might be able to do something in opam, but to my knowledge no such thing exist (and it's a bit too late anyway) so it's to the creator of the package to ensure the right arguments are given. opam-repo-ci will also soon test for this: ocurrent/opam-repo-ci#200 so once OCaml 4.14.2 / 5.0.1 is out we should be able to ensure this bug doesn't happen in opam-repository.

Do you want me to move this issue to the dune bugtracker?

@AllanBlanchard
Copy link
Author

Honestly, I didn't know whether I should post the issue here or in the Dune issue tracker 😅

I had a few discussion with @bobot about it, and it seems that it is indeed the expected behavior. I would say that I do not really agree with it neither. It is good to know that it will be tested in Opam repository in the future anyway! 👍

@kit-ty-kate kit-ty-kate transferred this issue from ocaml/opam Jan 27, 2023
@kit-ty-kate
Copy link
Member

I moved it to the dune repository to let the dune devs know of the discussion and if they want to reopen it in case they want to change this behaviour in the future.

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

No branches or pull requests

2 participants