Skip to content

Commit 5c32376

Browse files
committed
Fix pinned depends being ignored on simulated pins
1 parent d9bac17 commit 5c32376

File tree

3 files changed

+100
-27
lines changed

3 files changed

+100
-27
lines changed

src/client/opamAuxCommands.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ let autopin st ?(simulate=false) ?quiet ?locked ?recurse ?subpath
545545
else
546546
OpamUpdate.dev_packages st ~working_dir:OpamPackage.Set.empty already_pinned
547547
in
548+
let st =
549+
(* NOTE: We skip pin-depends on non-simulated because handle_pin_depends has
550+
already been called in source_pin *)
551+
if not simulate || OpamClientConfig.(!r.ignore_pin_depends) then st else
552+
OpamPackage.Set.fold (fun nv st ->
553+
OpamPinCommand.handle_pin_depends st nv (OpamSwitchState.opam st nv))
554+
(OpamPackage.Set.union pins already_pinned_set) st
555+
in
548556
st, simulate_pinned_atoms pins atoms
549557

550558
let check_and_revert_sandboxing root config =

tests/reftests/autopin.test

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,31 @@ No solution found, exiting
343343
# Return code 20 #
344344
### opam pin
345345
### opam install --deps-only ./local-with-pin-deps
346-
[ERROR] Package conflict!
347-
* Missing dependency:
348-
- deps-of-local-with-pin-deps -> pin-dep
349-
unknown package
346+
The following additional pinnings are required by local-with-pin-deps.dev:
347+
- pin-dep.dev at file://${BASEDIR}/pin-dep
348+
Pin and install them? [Y/n] y
349+
[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch.
350+
[pin-dep.dev] synchronised (no changes)
351+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
352+
The following actions will be performed:
353+
=== install 1 package
354+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
350355

351-
No solution found, exiting
352-
# Return code 20 #
356+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
357+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
358+
-> installed pin-dep.dev
359+
Done.
353360
### opam pin
361+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
354362
### opam pin remove pin-dep
355-
[NOTE] pin-dep is not pinned.
363+
Ok, pin-dep is no longer pinned to file://${BASEDIR}/pin-dep (version dev)
364+
The following actions will be performed:
365+
=== remove 1 package
366+
- remove pin-dep dev
367+
368+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
369+
-> removed pin-dep.dev
370+
Done.
356371
### opam pin
357372
### opam install ./local-with-pin-deps
358373
[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch.
@@ -398,6 +413,10 @@ Switch invariant: ["ocaml" {>= "4.05.0"}]
398413
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
399414
# Return code 20 #
400415
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
416+
The following additional pinnings are required by local-with-pin-deps.dev:
417+
- pin-dep.dev at file://${BASEDIR}/pin-dep
418+
Pin and install them? [Y/n] n
419+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
401420

402421
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
403422
Switch invariant: ["ocaml" {>= "4.05.0"}]

tests/reftests/pin-depends.test

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ No solution found, exiting
4040
### :I:1:c: Deps only without pin depends
4141
### opam switch create pin-deps-I-1-c --empty
4242
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install --deps-only ./local-with-pin-deps
43+
The following additional pinnings are required by local-with-pin-deps.dev:
44+
- pin-dep.dev at file://${BASEDIR}/pin-dep
45+
Pin and install them? [Y/n] n
46+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
4347
[ERROR] Package conflict!
4448
* Missing dependency:
4549
- deps-of-local-with-pin-deps -> pin-dep
@@ -51,14 +55,24 @@ No solution found, exiting
5155
### :I:1:d: Deps only with pin depends
5256
### opam switch create pin-deps-I-1-d --empty
5357
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps
54-
[ERROR] Package conflict!
55-
* Missing dependency:
56-
- deps-of-local-with-pin-deps -> pin-dep
57-
unknown package
58+
The following additional pinnings are required by local-with-pin-deps.dev:
59+
- pin-dep.dev at file://${BASEDIR}/pin-dep
60+
Pin and install them? [Y/n] y
61+
[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch.
62+
[pin-dep.dev] synchronised (no changes)
63+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
64+
The following actions will be performed:
65+
=== install 1 package
66+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
5867

59-
No solution found, exiting
60-
# Return code 20 #
68+
Proceed with 1 installation? [Y/n] y
69+
70+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
71+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
72+
-> installed pin-dep.dev
73+
Done.
6174
### opam pin
75+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
6276
### :I:1:e: install without pin depends
6377
### opam switch create pin-deps-I-1-e --empty
6478
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes opam install ./local-with-pin-deps
@@ -134,6 +148,10 @@ Done.
134148
### :I:2:c: Deps only without pin depends
135149
### opam switch create pin-deps-I-2-c --empty
136150
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps
151+
The following additional pinnings are required by local-with-pin-deps.dev:
152+
- pin-dep.dev at file://${BASEDIR}/pin-dep
153+
Pin and install them? [Y/n] n
154+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
137155
The following actions will be performed:
138156
=== install 1 package
139157
- install pin-dep 1 [required by local-with-pin-deps]
@@ -147,14 +165,20 @@ Done.
147165
### :I:2:d: Deps only without pin depends
148166
### opam switch create pin-deps-I-2-d --empty
149167
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps
168+
The following additional pinnings are required by local-with-pin-deps.dev:
169+
- pin-dep.dev at file://${BASEDIR}/pin-dep
170+
Pin and install them? [Y/n] y
171+
[pin-dep.dev] synchronised (no changes)
172+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
150173
The following actions will be performed:
151174
=== install 1 package
152-
- install pin-dep 1 [required by local-with-pin-deps]
175+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
153176

154177
Proceed with 1 installation? [Y/n] y
155178

156179
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
157-
-> installed pin-dep.1
180+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
181+
-> installed pin-dep.dev
158182
Done.
159183
### :I:2:e: install without pin depends
160184
### opam switch create pin-deps-I-2-e --empty
@@ -215,6 +239,10 @@ pin-dep.dev rsync file://${BASEDIR}/pin-dep
215239
Now run 'opam upgrade' to apply any package updates.
216240
### :II:1:a: Answer no to pin depends install deps-only
217241
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
242+
The following additional pinnings are required by local-with-pin-deps.dev:
243+
- pin-dep.dev at file://${BASEDIR}/pin-dep
244+
Pin and install them? [Y/n] n
245+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
218246

219247
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
220248
Switch invariant: []
@@ -259,23 +287,30 @@ The compiler switch ${BASEDIR}/local-with-pin-deps does not exist.
259287
# Return code 5 #
260288
### :II:1:c: Answer yes to pin depends install deps-only
261289
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
290+
The following additional pinnings are required by local-with-pin-deps.dev:
291+
- pin-dep.dev at file://${BASEDIR}/pin-dep
292+
Pin and install them? [Y/n] y
293+
[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch.
294+
[pin-dep.dev] synchronised (no changes)
295+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
262296

263297
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
264298
Switch invariant: []
265-
[ERROR] Could not determine which packages to install for this switch:
266-
* Missing dependency:
267-
- local-with-pin-deps -> pin-dep
268-
unknown package
299+
[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades.
300+
The following actions will be performed:
301+
=== install 1 package
302+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
269303

304+
Proceed with 1 installation? [Y/n] y
270305

271-
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
272-
# Return code 20 #
306+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
307+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
308+
-> installed pin-dep.dev
309+
Done.
273310
### opam pin --switch=./local-with-pin-deps
274-
[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed.
275-
# Return code 2 #
311+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
276312
### opam switch remove ./local-with-pin-deps -y
277-
The compiler switch ${BASEDIR}/local-with-pin-deps does not exist.
278-
# Return code 5 #
313+
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
279314
### :II:1:d: Answer yes to pin depends install
280315
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps
281316
[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch.
@@ -313,6 +348,10 @@ Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are yo
313348
opam-version: "2.0"
314349
### :II:2:a: Answer no to pin depends install deps only
315350
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only
351+
The following additional pinnings are required by local-with-pin-deps.dev:
352+
- pin-dep.dev at file://${BASEDIR}/pin-dep
353+
Pin and install them? [Y/n] n
354+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
316355

317356
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
318357
Switch invariant: []
@@ -359,20 +398,27 @@ local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps
359398
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
360399
### :II:2:c: Answer yes to pin depends install deps-only
361400
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only
401+
The following additional pinnings are required by local-with-pin-deps.dev:
402+
- pin-dep.dev at file://${BASEDIR}/pin-dep
403+
Pin and install them? [Y/n] y
404+
[pin-dep.dev] synchronised (no changes)
405+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
362406

363407
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
364408
Switch invariant: []
365409
[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades.
366410
The following actions will be performed:
367411
=== install 1 package
368-
- install pin-dep 1 [required by local-with-pin-deps]
412+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
369413

370414
Proceed with 1 installation? [Y/n] y
371415

372416
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
373-
-> installed pin-dep.1
417+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
418+
-> installed pin-dep.dev
374419
Done.
375420
### opam pin --switch=./local-with-pin-deps
421+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
376422
### opam switch remove ./local-with-pin-deps -y
377423
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
378424
### :II:2:d: Answer yes to pin depends install

0 commit comments

Comments
 (0)