Closed scottmmjackson closed 3 years ago
It looks like this is caused by using eval.expr = TRUE
in get
:
Reverting https://github.com/rstudio/config/pull/17 does not fix this problem.
Hi guys, is anyone working on this issue? That's quite a blocker for deploying content to R Studio Connect by only using the keyring package. It would be very helpful to figure this one out!
This behavior comes from yaml::yaml.load_file()
. If the expression is not immediately evaluated (using eval.expr = FALSE
) then the resulting R list is:
$default
$default$foo
[1] "bar"
$development
$development$foo
[1] "development"
$irrelevant
$irrelevant$foo
[1] "BRRR::skrrrahh(sound = 26)"
The challenge here is that there's nothing indicating that the third entry in the list is actually an expression waiting for execution, which makes it difficult to defer execution to a later point.
@jimhester would you be the right person to ask about this? I know its a complicated matter since the yaml package is maintained separately. Alternatively, do you know who would be best equipped to show the config/keyring package some love?
I created a PR that I believe will fix the problem.
This should now be fixed in the master
branch. I added test cases and I believe the new code base will handle this use case. Can you please test locally and report any problems?
cc @slopp , @blairj09
Thank you for a great package and the fix. Unfortunately updating to v0.3.1 appears to break magrittr
pipes previously used within !expr
. Reproduction steps:
config.yml
default:
test: !expr 1 %>% add(1)
With v0.3:
library(magrittr)
> config::get(file = "config.yml")
$test
[1] 2
With v0.3.1:
library(magrittr)
> config::get(file = "config.yml")
Error in 1 %>% add(1) : could not find function "%>%"
@pmhogan , I'm sorry that this change broke your usage. As you discovered, the expressions are now handled in the base environment, so you will have to explicitly load external packages. Unfortunately this may cause you to duplicate some expressions, or to handle those expressions in your R script, rather than in the yaml expression.
Specifically, in your case:
default:
test: !expr library(magrittr); 1 %>% add(1)
Closing this issue, since this behaviour was included in 8a939b2
Reproduction steps:
config.yml
file in the content's folder:development: foo: development
irrelevant: foo: !expr BRRR::skrrrahh(sound = 26)