Skip to content

Commit ad14e49

Browse files
authored
Merge pull request #6947 from rjbou/var-fatal-locked
Fix `undefined variable` error when a lock file filter contains an undefined variable
2 parents 3de623d + d4da3fc commit ad14e49

3 files changed

Lines changed: 36 additions & 4 deletions

File tree

master_changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ users)
7070
* No longer call tar tool to create archives, use tar library instead [#6945 @kit-ty-kate]
7171

7272
## Lock
73+
* [BUG] Fix `undefined variable` error when a lock file filter contains an undefined variables: fail gracefully with strict mode, continue and default the variable to false on normal mode [#6947 @rjbou - fix #6946]
7374

7475
## Clean
7576

@@ -180,6 +181,7 @@ users)
180181
* Fix trailing full path for `tar` call in `no-depexts-sandboxed.unix.test` [#6970 @rjbou]
181182
* Fix some forgotten sed in `extrasource` and `update` tests in #6734 [#6970 @rjbou]
182183
* Add a test for `opam config subst` [#6936 @NathanReb]
184+
* Add a lock test for undefined variables in a lock file [#6947 @rjbou - fix #6946]
183185

184186
### Engine
185187
* Add `http-server` to launch a minimal http server [#6939 @rjbou]

src/state/opamPinned.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ let check_locked ?locked default =
6666
OpamPackage.Name.Set.empty lock_depends
6767
in
6868
let base_formula =
69-
OpamFilter.filter_deps ~build:true ~post:true ~test:false ~doc:false
70-
~dev_setup:false ~dev:false base_depends
69+
OpamFilter.filter_deps ~default:false ~build:true ~post:true
70+
~test:false ~doc:false ~dev_setup:false ~dev:false base_depends
7171
in
7272
let lock_formula =
73-
OpamFilter.filter_deps ~build:true ~post:true ~test:false ~doc:false
74-
~dev_setup:false ~dev:false lock_depends
73+
OpamFilter.filter_deps ~default:false ~build:true ~post:true
74+
~test:false ~doc:false ~dev_setup:false ~dev:false lock_depends
7575
in
7676
let lpkg_f =
7777
lock_formula

tests/reftests/lock.test

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,3 +1370,33 @@ name: "distant-x"
13701370
opam-version: "2.0"
13711371
pin-depends: [["local-one.dev" "file://${BASEDIR}/local-one"] ["local-two.dev" "file://${BASEDIR}/local-two"]]
13721372
version: "1"
1373+
### : Undefined variables in lock files shouldn't fail on non strict mode :
1374+
### <pin:with-nope/with-nope.opam>
1375+
opam-version: "2.0"
1376+
### <pin:with-nope/with-nope.opam.locked>
1377+
opam-version: "2.0"
1378+
depends: [ "nope" {with-nope} ]
1379+
### # we need to disable strict mode to see the default behaviour
1380+
### OPAMSTRICT=0
1381+
### opam switch create undef-var --empty
1382+
### opam pin ./with-nope --locked
1383+
[NOTE] Package with-nope does not exist in opam repositories registered in the current switch.
1384+
with-nope is now pinned to file://${BASEDIR}/with-nope (version dev)
1385+
1386+
The following actions will be performed:
1387+
=== install 1 package
1388+
- install with-nope dev (pinned)
1389+
1390+
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
1391+
-> retrieved with-nope.dev (file://${BASEDIR}/with-nope)
1392+
-> installed with-nope.dev
1393+
Done.
1394+
### OPAMSTRICT=1
1395+
### opam switch create undef-var-strict --empty
1396+
### opam pin ./with-nope --locked
1397+
[NOTE] Package with-nope does not exist in opam repositories registered in the current switch.
1398+
with-nope is now pinned to file://${BASEDIR}/with-nope (version dev)
1399+
1400+
[ERROR] Undefined filter variable with-nope in dependencies of with-nope.dev
1401+
[NOTE] Pinning command successful, but your installed packages may be out of sync.
1402+
# Return code 30 #

0 commit comments

Comments
 (0)