-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
with_language() fails to reset the cache on Alpine Linux #213
Comments
cc @hadley |
@KevCaz noticed this bug in my post about potools I observe the same behavior as @bastistician (on Ubuntu) library("withr")
with_language("en", try(mean[[1]]))
#> Error in mean[[1]] : object of type 'closure' is not subsettable
with_language("fr", try(mean[[1]]))
#> Error in mean[[1]] : objet de type 'closure' non indiçable
with_language("es", try(mean[[1]]))
#> Error in mean[[1]] : objeto de tipo 'closure' no es subconjunto
try(mean[[1]])
#> Error in mean[[1]] : objeto de tipo 'closure' no es subconjunto
with_language("fr", try(mean[[1]]))
#> Error in mean[[1]] : objet de type 'closure' non indiçable
try(mean[[1]])
#> Error in mean[[1]] : objet de type 'closure' non indiçable Created on 2023-10-09 with reprex v2.0.2 |
I had to also set @hadley I wonder if we should try and set it automatically if not set already? We'd use some country as default for each language. To override, the user could supply a length-2 character vector. It might be tricky to have the mapping be both comprehensive and cross-platform. |
I had to change the locale code to make your example work on my machine but that seems to be expected for different OS. 😅 It seems to work! with_lang <- function(lc, language, expr) {
withr::local_envvar(c(LC_ALL = lc))
withr::local_language(language)
expr
}
with_lang("fr_FR.UTF-8", "fr", try(mean[[1]]))
#> Error in mean[[1]] : objet de type 'closure' non indiçable
try(mean[[1]])
#> Error in mean[[1]] : object of type 'closure' is not subsettable Created on 2023-10-09 with reprex v2.0.2 |
@lionel- do we need to set |
After some reading including https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=931456 and https://bugs.r-project.org/show_bug.cgi?id=18055 here is my understanding of things:
|
Thanks for checking! |
withr/R/language.R
Lines 48 to 50 in 35301f6
Yes there is: musl-based Alpine Linux.
example("with_language")
gives:All subsequent invocations of that error message stick to French.
R CMD checking withr fails for me from
withr/tests/testthat/test-language.R
Line 6 in 35301f6
due to this issue.
In R >= 4.2.0,
bindtextdomain(NULL)
could be used to flush the cache, as inSys.setLanguage()
. This works on Alpine Linux:sessionInfo()
The text was updated successfully, but these errors were encountered: