Skip to content

Commit baff567

Browse files
committed
Fix pinned depends being ignored on simulated pins
1 parent 9b79ad3 commit baff567

File tree

3 files changed

+118
-27
lines changed

3 files changed

+118
-27
lines changed

src/client/opamAuxCommands.ml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,12 @@ 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+
if OpamClientConfig.(!r.ignore_pin_depends) then st else
550+
OpamPackage.Set.fold (fun nv st ->
551+
OpamPinCommand.handle_pin_depends st nv (OpamSwitchState.opam st nv))
552+
(OpamPackage.Set.union pins already_pinned_set) st
553+
in
548554
st, simulate_pinned_atoms pins atoms
549555

550556
let check_and_revert_sandboxing root config =

tests/reftests/autopin.test

Lines changed: 30 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.
@@ -386,6 +401,10 @@ The following additional pinnings are required by local-with-pin-deps.dev:
386401
Pin and install them? [Y/n] n
387402
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
388403
local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev)
404+
The following additional pinnings are required by local-with-pin-deps.dev:
405+
- pin-dep.dev at file://${BASEDIR}/pin-dep
406+
Pin and install them? [Y/n] n
407+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
389408

390409
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
391410
Switch invariant: ["ocaml" {>= "4.05.0"}]
@@ -398,6 +417,10 @@ Switch invariant: ["ocaml" {>= "4.05.0"}]
398417
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
399418
# Return code 20 #
400419
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
420+
The following additional pinnings are required by local-with-pin-deps.dev:
421+
- pin-dep.dev at file://${BASEDIR}/pin-dep
422+
Pin and install them? [Y/n] n
423+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
401424

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

tests/reftests/pin-depends.test

Lines changed: 82 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
@@ -68,6 +82,10 @@ The following additional pinnings are required by local-with-pin-deps.dev:
6882
Pin and install them? [Y/n] n
6983
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
7084
local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev)
85+
The following additional pinnings are required by local-with-pin-deps.dev:
86+
- pin-dep.dev at file://${BASEDIR}/pin-dep
87+
Pin and install them? [Y/n] n
88+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
7189
[ERROR] Package conflict!
7290
* Missing dependency:
7391
- local-with-pin-deps -> pin-dep
@@ -134,6 +152,10 @@ Done.
134152
### :I:2:c: Deps only without pin depends
135153
### opam switch create pin-deps-I-2-c --empty
136154
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps
155+
The following additional pinnings are required by local-with-pin-deps.dev:
156+
- pin-dep.dev at file://${BASEDIR}/pin-dep
157+
Pin and install them? [Y/n] n
158+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
137159
The following actions will be performed:
138160
=== install 1 package
139161
- install pin-dep 1 [required by local-with-pin-deps]
@@ -147,14 +169,20 @@ Done.
147169
### :I:2:d: Deps only without pin depends
148170
### opam switch create pin-deps-I-2-d --empty
149171
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam install --deps-only ./local-with-pin-deps
172+
The following additional pinnings are required by local-with-pin-deps.dev:
173+
- pin-dep.dev at file://${BASEDIR}/pin-dep
174+
Pin and install them? [Y/n] y
175+
[pin-dep.dev] synchronised (no changes)
176+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
150177
The following actions will be performed:
151178
=== install 1 package
152-
- install pin-dep 1 [required by local-with-pin-deps]
179+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
153180

154181
Proceed with 1 installation? [Y/n] y
155182

156183
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
157-
-> installed pin-dep.1
184+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
185+
-> installed pin-dep.dev
158186
Done.
159187
### :I:2:e: install without pin depends
160188
### opam switch create pin-deps-I-2-e --empty
@@ -165,6 +193,10 @@ The following additional pinnings are required by local-with-pin-deps.dev:
165193
Pin and install them? [Y/n] n
166194
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
167195
local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev)
196+
The following additional pinnings are required by local-with-pin-deps.dev:
197+
- pin-dep.dev at file://${BASEDIR}/pin-dep
198+
Pin and install them? [Y/n] n
199+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
168200
The following actions will be performed:
169201
=== install 2 packages
170202
- install local-with-pin-deps dev (pinned)
@@ -215,6 +247,10 @@ pin-dep.dev rsync file://${BASEDIR}/pin-dep
215247
Now run 'opam upgrade' to apply any package updates.
216248
### :II:1:a: Answer no to pin depends install deps-only
217249
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
250+
The following additional pinnings are required by local-with-pin-deps.dev:
251+
- pin-dep.dev at file://${BASEDIR}/pin-dep
252+
Pin and install them? [Y/n] n
253+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
218254

219255
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
220256
Switch invariant: []
@@ -240,6 +276,10 @@ The following additional pinnings are required by local-with-pin-deps.dev:
240276
Pin and install them? [Y/n] n
241277
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
242278
local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev)
279+
The following additional pinnings are required by local-with-pin-deps.dev:
280+
- pin-dep.dev at file://${BASEDIR}/pin-dep
281+
Pin and install them? [Y/n] n
282+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
243283

244284
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
245285
Switch invariant: []
@@ -259,23 +299,30 @@ The compiler switch ${BASEDIR}/local-with-pin-deps does not exist.
259299
# Return code 5 #
260300
### :II:1:c: Answer yes to pin depends install deps-only
261301
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes:switch-clean-up=yes opam switch create ./local-with-pin-deps --deps-only
302+
The following additional pinnings are required by local-with-pin-deps.dev:
303+
- pin-dep.dev at file://${BASEDIR}/pin-dep
304+
Pin and install them? [Y/n] y
305+
[NOTE] Package pin-dep does not exist in opam repositories registered in the current switch.
306+
[pin-dep.dev] synchronised (no changes)
307+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
262308

263309
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
264310
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
311+
[NOTE] No invariant was set, you may want to use `opam switch set-invariant' to keep a stable compiler version on upgrades.
312+
The following actions will be performed:
313+
=== install 1 package
314+
- install pin-dep dev (pinned) [required by local-with-pin-deps]
269315

316+
Proceed with 1 installation? [Y/n] y
270317

271-
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
272-
# Return code 20 #
318+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
319+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
320+
-> installed pin-dep.dev
321+
Done.
273322
### opam pin --switch=./local-with-pin-deps
274-
[ERROR] The selected switch ${BASEDIR}/local-with-pin-deps is not installed.
275-
# Return code 2 #
323+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
276324
### opam switch remove ./local-with-pin-deps -y
277-
The compiler switch ${BASEDIR}/local-with-pin-deps does not exist.
278-
# Return code 5 #
325+
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
279326
### :II:1:d: Answer yes to pin depends install
280327
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps
281328
[NOTE] Package local-with-pin-deps does not exist in opam repositories registered in the current switch.
@@ -313,6 +360,10 @@ Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are yo
313360
opam-version: "2.0"
314361
### :II:2:a: Answer no to pin depends install deps only
315362
### OPAMAUTOANSWER=install-pin-depends=no:ignore-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only
363+
The following additional pinnings are required by local-with-pin-deps.dev:
364+
- pin-dep.dev at file://${BASEDIR}/pin-dep
365+
Pin and install them? [Y/n] n
366+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
316367

317368
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
318369
Switch invariant: []
@@ -337,6 +388,10 @@ The following additional pinnings are required by local-with-pin-deps.dev:
337388
Pin and install them? [Y/n] n
338389
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
339390
local-with-pin-deps is now pinned to file://${BASEDIR}/local-with-pin-deps (version dev)
391+
The following additional pinnings are required by local-with-pin-deps.dev:
392+
- pin-dep.dev at file://${BASEDIR}/pin-dep
393+
Pin and install them? [Y/n] n
394+
Try to install anyway, assuming `--ignore-pin-depends'? [Y/n] y
340395

341396
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
342397
Switch invariant: []
@@ -359,20 +414,27 @@ local-with-pin-deps.dev rsync file://${BASEDIR}/local-with-pin-deps
359414
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
360415
### :II:2:c: Answer yes to pin depends install deps-only
361416
### OPAMAUTOANSWER=install-pin-depends=yes:proceed-actions=yes opam switch create ./local-with-pin-deps --deps-only
417+
The following additional pinnings are required by local-with-pin-deps.dev:
418+
- pin-dep.dev at file://${BASEDIR}/pin-dep
419+
Pin and install them? [Y/n] y
420+
[pin-dep.dev] synchronised (no changes)
421+
pin-dep is now pinned to file://${BASEDIR}/pin-dep (version dev)
362422

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

370430
Proceed with 1 installation? [Y/n] y
371431

372432
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
373-
-> installed pin-dep.1
433+
-> retrieved pin-dep.dev (file://${BASEDIR}/pin-dep)
434+
-> installed pin-dep.dev
374435
Done.
375436
### opam pin --switch=./local-with-pin-deps
437+
pin-dep.dev rsync file://${BASEDIR}/pin-dep
376438
### opam switch remove ./local-with-pin-deps -y
377439
Switch ${BASEDIR}/local-with-pin-deps and all its packages will be wiped. Are you sure? [Y/n] y
378440
### :II:2:d: Answer yes to pin depends install

0 commit comments

Comments
 (0)