Skip to content

Commit f721a79

Browse files
committed
Reset the "jobs" config variable when upgrading from opam 2.0
1 parent 6eeffc7 commit f721a79

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

master_changes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ users)
7878
* Really install invariant formula if not installed in switch [#5188 @rjbou]
7979
* On import, check that installed pinned packages changed, reinstall if so [#5181 @rjbou - fix #5173]
8080

81+
## Config
82+
* Reset the "jobs" config variable when upgrading from opam 2.0 [#5284 @kit-ty-kate]
83+
8184
## Pin
8285
* Switch the default version when undefined from ~dev to dev [#4949 @kit-ty-kate]
8386
* ◈ New option `opam pin --current` to fix a package in its current state (avoiding pending reinstallations or removals from the repository) [#4973 @AltGr - fix #4970]

src/state/opamFormatUpgrade.ml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,20 @@ let from_2_1_alpha2_to_v2_1_rc root conf =
10741074

10751075
let from_2_1_rc_to_v2_1 _ conf = conf
10761076

1077-
let from_2_0_to_v2_1 _ conf = conf
1077+
let from_2_0_to_v2_1 _ conf =
1078+
(* In opam < 2.1 "jobs" was set during initialisation
1079+
This creates problems when upgrading from opam 2.0 as it
1080+
sets the job count for good even if the CPU is replaced.
1081+
See https://github.com/ocurrent/ocaml-dockerfile/pull/92 *)
1082+
(* We print a warning in case the previous value of 'jobs' does not
1083+
match the default in opam 2.0 as we can't determine if the value
1084+
was modified or if the hardware changed. *)
1085+
if OpamFile.Config.jobs conf = Some (OpamSysPoll.cores () - 1) then
1086+
OpamConsole.note
1087+
"The 'jobs' option was reset, its value was %d. \
1088+
If it really was intended, you can set it again using:\n \
1089+
opam option jobs=%d --global" j j;
1090+
OpamFile.Config.with_jobs_opt None conf
10781091

10791092
let latest_version = OpamFile.Config.root_version
10801093

0 commit comments

Comments
 (0)