Skip to content
New issue

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

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

Already on GitHub? # to your account

opam 2.1.4 fails to add a local repository if opam repo add is invoked from a "grandparent directory" #5632

Closed
BridgeTheMasterBuilder opened this issue Aug 14, 2023 · 3 comments · Fixed by #6027

Comments

@BridgeTheMasterBuilder
Copy link

Output of opam config report as requested:

# opam config report
# opam-version         2.1.4
# self-upgrade         no
# system               arch=x86_64 os=linux os-distribution=debian os-version=12
# 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                 3
# repositories         1 (http), 1 (local) (default repo at e46b804c)
# pinned               3 (git)
# current-switch       /home/master/coq
# ocaml:native         true
# ocaml:native-tools   true
# ocaml:native-dynlink true
# ocaml:stubsdir       /home/master/coq/_opam/lib/ocaml/stublibs:/home/master/coq/_opam/lib/ocaml
# ocaml:preinstalled   false
# ocaml:compiler       4.14.1+options+flambda

In this example I was trying to add opam-coq-archive/released as a local repository while in a directory coq which is the parent directory of opam-coq-archive, which results in the following:

opam repo add test opam-coq-released/released --debug
00:00.010  CLI                    Parsing CLI version 2.1
00:00.010  GSTATE                 LOAD-GLOBAL-STATE @ /home/master/.opam
00:00.010  RSTATE                 LOAD-REPOSITORY-STATE @ /home/master/.opam
00:00.078  CACHE(repository)      Loaded /home/master/.opam/repo/state-3AF31D16.cache in 0.067s
00:00.078  RSTATE                 Cache found
00:00.078  REPOSITORY             repository-add
00:00.078  SYSTEM                 rm /home/master/.opam/repo/state-3AF31D16.cache
00:00.082  FILE(repos-config)     Wrote /home/master/.opam/repo/repos-config in 0.000s
00:00.082  PARALLEL               Iterate over 1 task(s) with 3 process(es)
00:00.082  PARALLEL               Starting job 0 (worker 1/3): 0
00:00.082  REPOSITORY             update test from file:///home/master/coq/opam-coq-archive/opam-coq-released/released
00:00.082  RSYNC                  pull-repo-update
00:00.082  SYSTEM                 mkdir /home/master/.opam/repo/test.new
00:00.082  SYSTEM                 rmdir /home/master/.opam/repo/test.new
[ERROR] Could not update repository "test": rsync failed
00:00.085  PARALLEL               Job 0 finished
00:00.085  FILE(repos-config)     Wrote /home/master/.opam/repo/repos-config in 0.000s
00:00.085  CACHE(repository)      Writing the repository cache to ~/.opam/repo/state-3AF31D16.cache ...
00:00.441  CACHE(repository)      ~/.opam/repo/state-3AF31D16.cache written in 0.356s
00:00.441  REPOSITORY             repository-remove
00:00.441  SYSTEM                 rm /home/master/.opam/repo/state-3AF31D16.cache
00:00.446  FILE(repos-config)     Wrote /home/master/.opam/repo/repos-config in 0.000s
00:00.446  CACHE(repository)      Writing the repository cache to ~/.opam/repo/state-3AF31D16.cache ...
00:00.802  CACHE(repository)      ~/.opam/repo/state-3AF31D16.cache written in 0.356s
00:00.802  SYSTEM                 rmdir /home/master/.opam/repo/test
[ERROR] Initial repository fetch failed

However, if the command is invoked from opam-coq-archive or opam-coq-archive/released itself, it is fine:

opam repo add test released --debug
00:00.009  CLI                    Parsing CLI version 2.1
00:00.009  GSTATE                 LOAD-GLOBAL-STATE @ /home/master/.opam
00:00.010  RSTATE                 LOAD-REPOSITORY-STATE @ /home/master/.opam
00:00.077  CACHE(repository)      Loaded /home/master/.opam/repo/state-3AF31D16.cache in 0.067s
00:00.077  RSTATE                 Cache found
00:00.077  REPOSITORY             repository-add
00:00.077  SYSTEM                 rm /home/master/.opam/repo/state-3AF31D16.cache
00:00.082  FILE(repos-config)     Wrote /home/master/.opam/repo/repos-config in 0.000s
00:00.082  PARALLEL               Iterate over 1 task(s) with 3 process(es)
00:00.082  PARALLEL               Starting job 0 (worker 1/3): 0
00:00.082  REPOSITORY             update test from file:///home/master/coq/opam-coq-archive/released
00:00.082  RSYNC                  pull-repo-update
00:00.314  REPOSITORY             test: applying update from scratch at /home/master/.opam/repo/test.new
00:00.314  SYSTEM                 rmdir /home/master/.opam/repo/test
[test] Initialised
00:00.316  PARALLEL               Next task in job 0: /usr/bin/tar cfz /home/master/.opam/repo/test.tar.gz.tmp -C /home/master/.opam/repo test
Processing  1/1:
00:00.389  PARALLEL               Collected task for job 0 (ret:0)
00:00.907  opam-file              Duplicate descr in '/home/master/.opam/repo/test/packages/coq-mathcomp-analysis/coq-mathcomp-analysis.0.2.2/descr' and opam file
00:01.404  PARALLEL               Job 0 finished
00:01.405  FILE(repos-config)     Wrote /home/master/.opam/repo/repos-config in 0.000s
00:01.405  CACHE(repository)      Writing the repository cache to ~/.opam/repo/state-3AF31D16.cache ...
00:01.777  CACHE(repository)      ~/.opam/repo/state-3AF31D16.cache written in 0.373s
00:01.777  SYSTEM                 rmdir /home/master/.opam/repo/test
00:01.894  FILE(switch-config)    Wrote /home/master/coq/_opam/.opam-switch/switch-config in 0.000s
[NOTE] Repository test has been added to the selections of switch /home/master/coq only.
       Run `opam repository add test --all-switches|--set-default' to use it in all existing switches, or in newly
       created switches, respectively.
@rjbou
Copy link
Collaborator

rjbou commented Aug 22, 2023

In the failing output, the repository directory is /home/master/coq/opam-coq-archive/opam-coq-released/released, while in the successful output, repository directory is /home/master/coq/opam-coq-archive/released.
Can you confirm that /home/master/coq/opam-coq-archive/opam-coq-released/released exists?

@BridgeTheMasterBuilder
Copy link
Author

In the failing output, the repository directory is /home/master/coq/opam-coq-archive/opam-coq-released/released, while in the successful output, repository directory is /home/master/coq/opam-coq-archive/released. Can you confirm that /home/master/coq/opam-coq-archive/opam-coq-released/released exists?

It does not exist. It seems like I just made a typo, I'm sorry. This can be closed. The diagnostics could maybe specify the directory doesn't exist, though.

@kit-ty-kate
Copy link
Member

The diagnostics could maybe specify the directory doesn't exist, though.

I agree. Let's reopen until we get that. Contributions are welcome.

@kit-ty-kate kit-ty-kate reopened this Aug 22, 2023
punchagan added a commit to punchagan/opam that referenced this issue Sep 29, 2023
rjbou added a commit to punchagan/opam that referenced this issue Nov 23, 2023
Closes ocaml#5632

Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
rjbou added a commit to punchagan/opam that referenced this issue Aug 19, 2024
Closes ocaml#5632

Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
rjbou added a commit to punchagan/opam that referenced this issue Aug 21, 2024
Closes ocaml#5632

Co-authored-by: Raja Boujbel <raja.boujbel@ocamlpro.com>
@rjbou rjbou added this to the 2.3.0~alpha1 milestone Sep 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment