Closed ShixiangWang closed 2 years ago
I go further check and generate an example, get some strange results:
test.yml
default:
databases:
- !expr c("abc")
- ~/abc
dev:
databases:
- /opt/abc
- !expr Sys.getenv("R")
Don't work at default
> config::get("databases", "dev", file = "~/Downloads/test.yml")
[[1]]
[1] "abc"
[[2]]
[1] "~/abc"
However, if I remove any rows with !expr
, it works. I find that if insert a row with !expr
, it will be parsed as an individual list, while without, a character vector is generated.
If you use only named elements this should work as expected:
default:
databases:
db1: !expr c("abc")
db2: ~/abc
dev:
databases:
db1: /opt/abc
db2: !expr Sys.getenv("R")
@andrie Ohh, thanks for your illustration.
Is there any workarounds when the elements are not named?
The result config should be set to
expression(Sys.getenv("coco.dev_database"))
indev
config instead of the setting indefault
config.I debug in deep and find out that
merge_lists()
use recursive approach at default (can not be modified outside), when merge two lists without name, the following situation happens,4
cannot replace1
.