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

Opam "switch create" does not work with -w (--working-dir) #5060

Closed
vog opened this issue Feb 16, 2022 · 5 comments · Fixed by #5082
Closed

Opam "switch create" does not work with -w (--working-dir) #5060

vog opened this issue Feb 16, 2022 · 5 comments · Fixed by #5082

Comments

@vog
Copy link

vog commented Feb 16, 2022

The opam sub command "switch create" does not work with -w (--working-dir).

Steps to reproduce:

  1. Ensure that opam 2.1.2 is installed:
$ opam --version
2.1.2
  1. Create a fresh ~/.opam:
$ rm -rf ~/.opam
$ opam init -n --bare
  1. Create a "test" switch using "-w":
$ opam switch create -w test 4.13.1

Output:

$ opam switch create -w test 4.13.1

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml-base-compiler" {= "4.13.1"} | "ocaml-system" {= "4.13.1"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
∗ installed ocaml-options-vanilla.1
[ERROR] The compilation of ocaml-base-compiler.4.13.1 failed at "./configure --prefix=/.../.opam/test -C".

#=== ERROR while compiling ocaml-base-compiler.4.13.1 =========================#
# context     2.1.2 | linux/x86_64 |  | https://opam.ocaml.org#28fab8d8
# path        ~/.opam/test/.opam-switch/build/ocaml-base-compiler.4.13.1
# command     ~/.opam/opam-init/hooks/sandbox.sh build ./configure --prefix=/.../.opam/test -C
# exit-code   1
# env-file    ~/.opam/log/ocaml-base-compiler-17413-f67663.env
# output-file ~/.opam/log/ocaml-base-compiler-17413-f67663.out
### output ###
# bwrap: execvp ./configure: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-base-compiler 4.13.1
└─ 
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray         base
│ ∗ install base-threads          base
│ ∗ install base-unix             base
│ ∗ install ocaml-options-vanilla 1
└─ 

<><> ocaml-base-compiler.4.13.1 troubleshooting <><><><><><><><><><><><><><><><>
=> A failure in the middle of the build may be caused by build parallelism
      (enabled by default).
      Please file a bug report at https://github.com/ocaml/opam-repository/issues
=> You can try installing again including --jobs=1
      to force a sequential build instead.

Remarks:

  • The issue is independent from other options like "--jobs=1", "--no-install", "-v" or "-y".
  • The issue is independent from the selected compiler version.
  • The issue also appears for local switches.
    • The issue is independent from whether the command runs within a Git checkout or in an unversioned directory.
  • In any case, the issue disappears as soon as "-w" is left out.
@rjbou
Copy link
Collaborator

rjbou commented Feb 16, 2022

I see what is happening here. As working dir is requested, no source synchronisation is done. In fact it is not supposed to be given at switch creation with a repository packages. Opam shouldn't let you do that, or at least handle this specific case.
I'm curious, what did you try to do ?

@vog
Copy link
Author

vog commented Feb 16, 2022

@rjbou I'm using "-w" for "opam install", saw that it is a common option, and used it for "switch create" as well.

In opam 2.0.x this worked without issues, but the upgrade to 2.1.2 made it suddenly fail.

If "-w" is not supposed to work with all commands, maybe the documentation / "--help" output should be improved?

As a related note, I get strange errors on "opam install" as well, when using "-w", no matter if I do this on a version controlled or an unversioned directory.

For example, installing package "ocaml-syntax-shims" into a 4.06.0 switch in a Git versioned directory leads to (but succeeds when "-w" is left out):

# Error: I don't know about package ocaml-syntax-shims (passed through
# only-packages)

As another example, installing package "xmlm" into a 4.06.0 switch in a Git versioned directory leads to (but succeeds when "-w" is left out):

# Cannot find file ./pkg/pkg.ml.

@rjbou rjbou added this to To do in Opam 2.2.0 via automation Feb 16, 2022
@rjbou rjbou added this to the 2.2.0~alpha milestone Feb 16, 2022
@rjbou
Copy link
Collaborator

rjbou commented Feb 16, 2022

If "-w" is not supposed to work with all commands, maybe the documentation / "--help" output should be improved?

the manpage specifies that it have effect on locally pinned packages, so it should be a no-op in your case.

For the other errors, can you give the process to reproduce ? Like that i'll add them too to the test suite a fix in the same time.

See also this PR #4879, it fixes a very specific case too

@vog
Copy link
Author

vog commented Feb 17, 2022

Okay, so here is how to reproduce the "opam install" errors.

Some notes upfront:

  • I'm describing it with local switches because that is how I encountered them. They might or might not be reproducible with "normal" switches as well.
  • The same holds for the compiler version: I only tested this with 4.06.0, it might or might not be reproducible with other versions.

Steps to reproduce:

  1. Ensure opam 2.1.2
  2. opam init -n --bare
  3. opam switch create -vy --no-install test-switches/4.06.0 4.06.0
  4. opam install -vwy --switch test-switches/4.06.0 ocaml-syntax-shims
    • See below for error message
    • Note that without -w this works: opam install -vy --switch test-switches/4.06.0 ocaml-syntax-shims
  5. opam install -vwy --switch test-switches/4.06.0 xmlm
    • See below for error message
    • Note that without -w this works: opam install -vy --switch test-switches/4.06.0 xmlm

Error message for ocaml-syntax-shims:

### output ###
# Error: I don't know about package ocaml-syntax-shims (passed through
# only-packages)

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-syntax-shims 1.0.0
└─ 
╶─ No changes have been performed

Error message for xmlm:

### output ###
# Cannot find file ./pkg/pkg.ml.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build xmlm 1.4.0
└─ 
┌─ The following changes have been performed
│ ∗ install ocamlbuild 0.14.1
│ ∗ install topkg      1.0.5
└─ 

@rjbou
Copy link
Collaborator

rjbou commented Feb 18, 2022

Thanks for the detailled reports! PR opened

@rjbou rjbou moved this from To do to In progress in Opam 2.2.0 Feb 21, 2022
Opam 2.2.0 automation moved this from In progress to Done Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants