Skip to content

Commit 95c8c8e

Browse files
NathanRebkit-ty-kate
authored andcommitted
Fix opam config subst so it accepts aboslute paths
Signed-off-by: Nathan Rebours <nathan.rebours@ocamlpro.com>
1 parent 4c6c62c commit 95c8c8e

5 files changed

Lines changed: 7 additions & 13 deletions

File tree

master_changes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ users)
4040
## Switch
4141

4242
## Config
43+
* Fix `opam config subst` so it works with absolute paths [#6936 @NathanReb - fix #6925]
4344

4445
## Pin
4546

@@ -222,6 +223,7 @@ users)
222223
* `OpamSolution` remove the heuristic of recomputing depexts of additional (pinned) packages. [#6489 @arozovyk]
223224
* `OpamClient` update the system package status check for dependencies during `opam install --deps-only`, including support for pinned packages; also update this in `OpamAuxCommands.autopin` [#6489 @arozovyk]
224225
* `OpamSolution.get_depexts` remove no longer needed `recover` option that was used with `--depext-only` option [#6489 @arozovyk]
226+
* `OpamConfigCommand.subst` now takes a `filename` instead of a `basename` [#6936 @NathanReb]
225227

226228
## opam-repository
227229
* `OpamRepositoryPath` was moved to `opam-format` [#6917 @rjbou]

src/client/opamCommands.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ let config cli =
14791479
| Some `subst, (_::_ as files) ->
14801480
OpamGlobalState.with_ `Lock_none @@ fun gt ->
14811481
`Ok (OpamConfigCommand.subst gt
1482-
(List.map OpamFilename.Base.of_string files))
1482+
(List.map OpamFilename.of_string files))
14831483
| Some `pef, params ->
14841484
OpamGlobalState.with_ `Lock_none @@ fun gt ->
14851485
OpamSwitchState.with_ `Lock_none gt @@ fun st ->

src/client/opamConfigCommand.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,7 @@ let subst gt fs =
378378
log "config-substitute";
379379
OpamSwitchState.with_ `Lock_none gt @@ fun st ->
380380
let env = OpamPackageVar.resolve st in
381-
List.iter
382-
(fun b ->
383-
let file = OpamFilename.of_basename b in
384-
OpamFilter.expand_interpolations_in_file env file)
385-
fs
381+
List.iter (OpamFilter.expand_interpolations_in_file env) fs
386382

387383
let expand gt str =
388384
log "config-expand";

src/client/opamConfigCommand.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ val print_eval_env: csh:bool -> sexp:bool -> fish:bool -> pwsh:bool -> cmd:bool
3838
val list: 'a switch_state -> name list -> unit
3939

4040
(** Substitute files *)
41-
val subst: 'a global_state -> basename list -> unit
41+
val subst: 'a global_state -> filename list -> unit
4242

4343
(** Prints expansion of variables in string *)
4444
val expand: 'a global_state -> string -> unit

tests/reftests/config.test

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,6 @@ Done.
227227
### opam config subst some-dir/relative
228228
### cat some-dir/relative
229229
${BASEDIR}/OPAM
230-
### opam config subst $BASEDIR/some-dir/absolute | 'OpamSystem.File_not_found.*' -> 'OpamSystem.File_not_found...'
231-
Fatal error:
232-
OpamSystem.File_not_found...
233-
# Return code 99 #
230+
### opam config subst $BASEDIR/some-dir/absolute
234231
### cat some-dir/absolute
235-
cat: some-dir/absolute: No such file or directory
236-
# Return code 1 #
232+
${BASEDIR}/OPAM

0 commit comments

Comments
 (0)