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

No documentation on loading state & their lock leads to read-only access to the opam 2.2 state fails when opam-state 2.1.* is used #5487

Open
kit-ty-kate opened this issue Mar 21, 2023 · 1 comment · May be fixed by #5488

Comments

@kit-ty-kate
Copy link
Member

#=== ERROR while compiling opam-dune-lint.0.2 =================================#
# context              2.2.0~alpha~dev | linux/x86_64 | ocaml-base-compiler.4.14.1 | file:///home/opam/opam-repository
# path                 ~/.opam/4.14/.opam-switch/build/opam-dune-lint.0.2
# command              ~/.opam/opam-init/hooks/sandbox.sh build dune build -p opam-dune-lint -j 255 @install @runtest
# exit-code            1
# env-file             ~/.opam/log/opam-dune-lint-7-c1162b.env
# output-file          ~/.opam/log/opam-dune-lint-7-c1162b.out
### output ###
# File "tests/test_vendoring.t", line 1, characters 0-0:
# File "tests/test_empty_dune.t", line 1, characters 0-0:
# File "tests/test_dune.t", line 1, characters 0-0:
#          git (internal) (exit 1)
# (cd _build/.sandbox/3887dc4e8b1d66b4fd37e214ba236a87/default && /usr/bin/git --no-pager diff --no-index --color=always -u ../../../default/tests/test_dune.t tests/test_dune.t.corrected)
# diff --git a/../../../default/tests/test_dune.t b/tests/test_dune.t.corrected
# index 35227f0..c5e6ec7 100644
# --- a/../../../default/tests/test_dune.t
# +++ b/tests/test_dune.t.corrected
# @@ -33,23 +33,20 @@ Replace all version numbers with "1.0" to get predictable output.
#  Check that the missing libraries are detected:
#  
#    $ opam-dune-lint </dev/null
# -  test.opam: changes needed:
# -    "fmt" {>= "1.0"}                         [from /]
# -    "bos" {with-test & >= "1.0"}             [from /]
# -    "opam-state" {with-test & >= "1.0"}      [from /]
# -  Note: version numbers are just suggestions based on the currently installed version.
# -  Run with -f to apply changes in non-interactive mode.
# -  [1]
# +  [ERROR] Refusing write access to /home/opam/.opam, which is more recent than this version of opam (2.2~alpha > 2.1), aborting.
# +  opam-dune-lint: internal error, uncaught exception:
# +                  OpamStd.OpamSys.Exit(15)
# +                  
# +  [125]

According to @rjbou this is unintended behaviour and using 2.1 library with a 2.2 root should work as long as it is in read-only mode.
Looking into the source of opam-dune-lint.0.2, only one lock access to opam root can be found and it is indeed read-only:

$ opam source opam-dune-lint.0.2
$ cd opam-dune-lint.0.2
$ grep -R Lock
index.ml:  OpamGlobalState.with_ `Lock_none @@ fun gt ->
@rjbou
Copy link
Collaborator

rjbou commented Mar 21, 2023

the issue is mainly in opam-dune-lint, and opam api documentation. With the patch applied in ocurrent/opam-dune-lint#36 (ie specifying which lock is required), there is write issue. To preserve unwanted writes, opam takes a write lock by default.
There is no documentation on that behaviour, we need to update it.

@rjbou rjbou changed the title Read-only access to the opam 2.2 state fails when opam-state 2.1.* is used No documentation on loading state & their lock leads to read-only access to the opam 2.2 state fails when opam-state 2.1.* is used Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants