Open GauthierMagnin opened 2 years ago
Thanks for reporting this.
In my R session, calls to
gettext
return French text whereas the functionsetTimeLimit
originally leads to an error written in English.
I'm a bit puzzled why you end up getting to English error message when you use setTimeLimit()
, because looking at the R source(*) we see:
error(_("reached elapsed time limit"))
error(_("reached CPU time limit"));
and those _(str)
calls are what translate str
into the local language via the gettext
framework. It sounds like something in your cases manages to cirtcumvent that.
I also have a package test since way-back that is supposed to test this;
As a starter, can you verify that that test works on your machine? If so, then it means there's something with your example that makes it work differently. I don't disagree with your conservative approach to add a fallback solution, and I think it's worthwhile, but it would be helpful to understand why it's needed and under what circumstances.
(*) On Linux & macOS:
BTW, what's your sessionInfo()
?
Here is my session information:
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] statnet.common_4.5.0 lattice_0.20-41 fansi_0.4.2 gtools_3.8.2
[5] crayon_1.4.1 utf8_1.2.1 R.methodsS3_1.8.1 grid_4.0.5
[9] lifecycle_1.0.0 magrittr_2.0.1 coda_0.19-4 pillar_1.6.0
[13] rlang_0.4.11 R.oo_1.24.0 R.utils_2.11.0 vctrs_0.3.8
[17] sna_2.6 ellipsis_0.3.2 tools_4.0.5 network_1.17.1
[21] compiler_4.0.5 pkgconfig_2.0.3 tibble_3.1.1
The test gives me the same error. The reason may be that I do not have an environment variable named "LANGUAGE": Sys.getenv("LANGUAGE")
returns ""
.
I understand that this may not be the case for everyone. However, if this variable is not set by default, there are probably many people who are in the same situation as me. This is why it should be useful to change the way the function works even if I set the environment variable on my computer. (Or at least specify in the documentation the need to have this variable.)
The test gives me the same error. The reason may be that I do not have an environment variable named "LANGUAGE":
Sys.getenv("LANGUAGE")
returns""
.
This plus knowing you're on MS Windows is helpful. I'll see if I can come up with a way to reproduce, especially on GitHub Actions. For instance, it could be that the existing test fails to change the language on MS Windows in the first place, so it's never testing the language feature.
I understand that this may not be the case for everyone. ...
Totally agree. This should be fixed if it's not working the same way regardless of operating system, OS configuration, and language setup. I just want to narrow in on the actual cause, because decided on the best fix and to be able to add an informative source code comment for why a fallback solution is added.
BTW, since my last comment, I realize that the current implementation of withTimeout()
assumes that the code evaluated does not change the language temporarily. That, alone, could be a reason for the fallback you propose.
UPDATE: Migrated below comment to Issue #140, because it's not the same problem
Thanks again for reporting. I can reproduce this on MS Windows with R 4.2.1 as:
...
Actually, I think what I found was another limitation of withTimeout()
, which is unrelated to your case. I've created Issue #140 to track that one.
So, back to your problem. I've tried to reproduce your problem using your code while first setting:
Sys.setlocale("LC_ALL", "French_France.1252")
but I fail. I've tried both R 4.2.1 and R 4.0.3 on an English-configured MS Windows 10.
In order to solve your problem, we need to narrow in on your exact setup;
Do you still experience the problem? (It could be that you moved to a newer version of R)
If still a problem, can you reproduce it in a fresh R session, i.e. try with Rterm --vanilla
? (In your session info above, there are a few other packages loaded; to rule out those, please retry without them)
I first tried to reproduce after restarting the session outside of any project and loading R.utils
only. I experienced the same problem. Here is the related session information:
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
[3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
[5] LC_TIME=French_France.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] R.utils_2.12.0-9005 R.oo_1.25.0 R.methodsS3_1.8.2
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5
I then tried using the callr::r_vanilla
function. In this case, it worked as expected.
(Back in April I somehow extracted your function, add the workaround I suggested as well as a link to this issue, considering changing it back to a call to your package once a fix is eventually applied).
Thanks for this update. It's a small, but one step closer for me to reproduce this. It's key that I can reproduce it so I can understand what's going on, before adding a patch. This is one of these things that you either do right from the beginning, or repeat many times (e.g. for users with other language setups).
So, more follow up questions:
Are you running R from the Windows command line?
Are you running R.exe
or Rterm.exe
?
Can you repeat the problem with Rterm.exe --vanilla
?
What does Sys.getenv("LANG")
give you run in a vanilla R session?
In a vanilla R session, what is the output of stop("boom")
? I'm interested in whether or not the "Error:" prefix is translated.
Finally, what does the following output in a vanilla R session?
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
1/2/3. I only use files and console in RStudio. I tried to run it with R and Rterm in a terminal but didn't manage to make any R code work that way. I feel like I'm missing an obvious thing there.
This is the reason why I used callr::r_vanilla
instead.
Sys.getenv("LANG")
returns ""
.Error in Sys.sleep(0.3) : la limite de temps est atteinte
whereas it is entirely in English outside of a vanilla process: Error in Sys.sleep(0.3) : reached elapsed time limit
.4 and 5 have the same behavior regardless the vanilla consideration.
1/2/3. I only use files and console in RStudio.
Oh... I had no idea. This is a game changer when it comes to troubleshooting.
So, what happens to 4, 5, and 6, when you run from within the RStudio Console? Please cut'n'paste both the input and the output exactly as it appears in RStudio.
Well, I simply wrapped in a function the code you asked me to run and used it as first argument of callr::r_vanilla
. Only the result of the function is returned, so I added a call to sink
so I can read the intermediate messages generated in a text file.
It looks like this:
callr::r_vanilla(
func = function() {
file <- file("test.txt", open = "wt")
sink(file)
sink(file, type = "message")
on.exit({
sink()
})
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
},
libpath = .libPaths()
)
and the output messages are the following:
1
2
3
4
Error in Sys.sleep(0.3) : la limite de temps est atteinte
And here is the output of running .Last.error
after that:
<callr_error/rlib_error_3_0/rlib_error/error>
Error:
! error in callr subprocess
Caused by error in `Sys.sleep(0.3)`:
! la limite de temps est atteinte
---
Backtrace:
1. callr::r_vanilla(func = function() {
2. callr::r(func, args = args, libpath = libpath, repos = repos, cmdargs = cmdargs,
3. callr:::get_result(output = out, options)
4. callr:::throw(callr_remote_error(remerr))
5. callr:::callr_remote_error(remerr)
6. callr:::throw(err, parent = remerr[[3]])
---
Subprocess backtrace:
1. global (function() {
2. base::Sys.sleep(0.3)
3. base::.handleSimpleError(function (e)
4. global h(simpleError(msg, call))
As I said, except this one, results are the same for 4 and 5 with or without the use of r_vanilla
I'm interested in what:
stop("boom")
and
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
produces in your RStudio Console session? AFAIU, that's where you came from when you first reported this problem.
Already answered that:
Sys.getenv("LANG")
returns""
.- The "Error:" prefix appears as is and is is not translated into French.
- Here I got an error message mixing English and French:
Error in Sys.sleep(0.3) : la limite de temps est atteinte
whereas it is entirely in English outside of a vanilla process:Error in Sys.sleep(0.3) : reached elapsed time limit
.4 and 5 have the same behavior regardless the vanilla consideration.
stop("boom")
Error: boom
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
1
2
3
4
Error in Sys.sleep(0.3) : reached elapsed time limit
Thanks. I still don't understand what is actually happening on your end, because in your original post you wrote:
After taking a look at how the function works, I noticed the use of the following instructions, which seems to be the issue:
pattern <- gettext("reached elapsed time limit", "reached CPU time limit", domain="R") pattern <- paste(pattern, collapse = "|") if (regexpr(pattern, msg) != -1L)
In my R session, calls to
gettext
return French text whereas the functionsetTimeLimit
originally leads to an error written in English.
So, the latter part is re-confirmed with the setTimeLimit()
output that you just shared; that part does not get translated. This is really weird, because if that does not get translated, then the gettext()
code shouldn't either. So, can you show me what:
gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
outputs? Again, do this in your RStudio Console session.
gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
[1] "la limite de temps est atteinte" "limite de temps processeur atteinte"
Wow, this is truly weird. And still you get:
> stop("boom")
Error: boom
So, now I'm on a quest to reproduce:
> stop("boom")
#> Error: boom
> gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
#> [1] "la limite de temps est atteinte" "limite de temps processeur atteinte"
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
#> 1
#> 2
#> 3
#> 4
#> Error in Sys.sleep(0.3) : reached elapsed time limit
It does not make sense to me that gettext()
translates when the other two doesn't.
FYI, when I try in RStudio Console (RStudio 2022.07.1+554) running R 4.2.1 on Ubuntu 20.04, with LANGUAGE=fr
set, I get:
> stop("boom")
Erreur : boom
> gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
[1] "la limite de temps est atteinte"
[2] "limite de temps processeur atteinte"
> local({
+ setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
+ for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
+ })
1
2
3
4
Erreur dans Sys.sleep(0.3) : la limite de temps est atteinte
>
But it seems to be an issue about the way R works, not about your package, right?
But it seems to be an issue about the way R works, not about your package, right?
Correct. If this is a bug in R itself, or RStudio, then this should be reported upstream and fixed there. This is one reason why I don't want to add "patches" that fix a symptom - it's always better to fix the root cause.
I'm still really confused how this can happen, and I doubt I'll be able to reproduce it. Do you have someone else near you with a French setup that you can check with? Do they also see this inconsistent set of translation when they call:
stop("boom")
gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
local({
setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
})
?
BTW, what output do you get if you call:
warning("whoops")
> warning("whoops")
Warning message:
whoops
I just asked a colleague to run the same instructions.
He uses R version 4.2.1. His locale is French_Canada.utf8
and all the results are the same as mine.
He uses R version 4.2.1. His locale is
French_Canada.utf8
and all the results are the same as mine.
Thanks.
BTW, what version of RStudio are you on? And your colleague?
Next, It would be useful to narrow down whether this is R or RStudio causing problems. In RStudio, there is the option to run R via the Terminal. In the English menu, it's under Tools -> Terminal -> New Terminal (Alt+Shift+R). This will open the 'Terminal' tab inside RStudio. In this terminal, what does:
which R
which Rscript
Rscript --version
report?
Oh, I forgot, those commands do not work on MS Windows. On MS Windows, use:
where R
where Rscript
Rscript --version
Here is what I get:
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ which R
/c/Program Files/R/R-4.0.5/bin/x64/R
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ which Rscript
/c/Program Files/R/R-4.0.5/bin/x64/Rscript
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ where R
C:\Program Files\R\R-4.0.5\bin\x64\R.exe
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ where Rscript
C:\Program Files\R\R-4.0.5\bin\x64\Rscript.exe
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ Rscript --version
R scripting front-end version 4.0.5 (2021-03-31)
I use Git Bash as terminal. Maybe this is the reason both which
and where
commands work.
My colleague and I use the same version of RStudio: RStudio 2022.07.1+554 "Spotted Wakerobin" Release (7872775ebddc40635780ca1ed238934c3345c5de, 2022-07-22) for Windows Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.12.8 Chrome/69.0.3497.128 Safari/537.36
Great. Now, in that terminal, please launch R and run those commands again, e.g.
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ R
...
> stop("boom")
...
> gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
...
> local({
+ setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
+ for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
+ })
...
Please cut'n'paste the full output, including the startup message of R.
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ R
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.
> stop("boom")
Erreur : boom
> gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
[1] "la limite de temps est atteinte" "limite de temps processeur atteinte"
> local({
+ setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
+ for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
+ })
1
2
3
4
Error in Sys.sleep(0.3) : la limite de temps est atteinte
Only one translation is missing this time.
Great, I hope we'ere getting closer to something. Now, what if you do the same, but launch R in vanilla mode;
$ R --vanilla
...
Same results.
Gauthier@DESKTOP-QMES3OL MINGW64 ~/Desktop/R.utils_issue
$ R --vanilla
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.
> stop("boom")
Erreur : boom
> gettext("reached elapsed time limit", "reached CPU time limit", domain="R")
[1] "la limite de temps est atteinte" "limite de temps processeur atteinte"
> local({
+ setTimeLimit(cpu = 1.0, elapsed = 1.0, transient = TRUE)
+ for (kk in 1:10) { message(kk); Sys.sleep(0.3) }
+ })
1
2
3
4
Error in Sys.sleep(0.3) : la limite de temps est atteinte
This is great, in the sense that now we have ruled out (i) RStudio, and (ii) any Rprofile or Renviron files of yours or the site-wide settings.
It could still be the core R installation settings. To figure that out, you need to install the startup package from CRAN, the start R in vanilla mode again and call startup::startup(dryrun = TRUE)
;
$ R --vanilla
...
> startup::startup(dryrun = TRUE)
...
You'll get a fair bit of output from that. Can you please share that here. Then I'll compare it, with what I get on my end. Maybe that'll reveal something.
PS. If I haven't already made it clear... this is a really weird behavior, and I've never heard of it before and is certainly not how R should behave.
I understand it is a weird unexpected behavior and I totally aggree with the idea of fixing the root cause rather than fixing a symptom. That's why I continue to follow your instructions even if my problem was solved with my first comment. Glad I can help try to improve anything.
Another fact (which maybe I should have remembered earlier): RStudio UI does not exist in French so I have an English interface. I always thought that was the reason why I sometimes get error messages in English and sometimes in French. So I didn't give it that much importance until the issue with withTimeout
.
$ R --vanilla
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.
> startup::startup(dryrun = TRUE)
0.000s: System information:
0.005s: - R_HOME: 'C:/PROGRA~1/R/R-40~1.5' (existing folder)
0.008s: - R call: C:\PROGRA~1\R\R-40~1.5/bin/x64/Rterm.exe --vanilla
0.011s: - Current directory: 'C:/Users/Gauthier/Desktop/R.utils_issue'
0.015s: - User's home directory: '~' => 'C:/Users/Gauthier/Ch' (existing folder)
0.019s: - User's 'startup' config directory: 'C:\Users\Gauthier\AppData\Local\R\config\R\startup' (non-existing directory)
0.023s: - Search path: '.GlobalEnv', 'package:stats', 'package:graphics', 'package:grDevices', 'package:utils', 'package:datasets', 'package:methods', 'Autoloads', 'package:base'
0.032s: - Loaded namespaces: 'compiler', 'startup', 'graphics', 'utils', 'grDevices', 'stats', 'datasets', 'methods', 'base'
0.037s: The following has already been processed by R:
0.041s: - R_ENVIRON: ''
0.042s: - R_ENVIRON_USER: ''
0.045s: - tempdir(): 'C:\Users\Gauthier\AppData\Local\Temp\RtmpOQYMfC' (existing folder)
0.049s: - TMPDIR: 'C:\Users\Gauthier\AppData\Local\Temp'
0.052s: - TMP: 'C:\Users\Gauthier\AppData\Local\Temp'
0.055s: - TEMP: 'C:\Users\Gauthier\AppData\Local\Temp'
0.060s: - R_LIBS: ''
0.062s: - R_LIBS_SITE: ''
0.064s: - R_LIBS_USER: 'C:/Users/Gauthier/Ch/R/win-library/4.0'
0.068s: - R_SCRIPT_DEFAULT_PACKAGES (only if Rscript was used): ''
0.073s: - R_DEFAULT_PACKAGES: '' (= 'base,methods,datasets,utils,grDevices,graphics,stats')
0.083s: - 'C:/PROGRA~1/R/R-40~1.5/library/base/R/Rprofile' (126 code lines; 6079 bytes)
0.088s: - R_PROFILE: ''
0.090s: - R_PROFILE_USER: ''
0.092s: startup::startup()-specific processing ...
0.108s: - unloading the 'startup' package
0.110s: - Search path: '.GlobalEnv', 'package:stats', 'package:graphics', 'package:grDevices', 'package:utils', 'package:datasets', 'package:methods', 'Autoloads', 'package:base'
0.125s: - Loaded namespaces: 'compiler', 'graphics', 'utils', 'grDevices', 'stats', 'datasets', 'methods', 'base'
0.132s: startup::startup()-specific processing ... done
0.136s: The following will be processed next by R:
0.139s: - R_HISTFILE: ''
0.141s: - .First(): no such function on search()
0.145s: - Remaining packages per R_DEFAULT_PACKAGES to be attached by base::.First.sys() (in order):
0.151s: The following will be processed when R terminates:
0.156s: - .Last(): no such function on search()
0.160s: - .Last.sys(): no such function on search()
I've compared this to my R 4.0.5 on an MS Windows 10 VM, and everything looks the same. So, nothing funny in your startup process.
Let's see if your French translation files are alright. What does the following output for you with Rterm.exe --vanilla
?
local({
opwd <- setwd(file.path(R.home("library"), "translations"))
on.exit(setwd(opwd))
print(fs::dir_info(file.path("fr", "LC_MESSAGES"))[,1:5], n = Inf)
})
On my setup, I get:
# A tibble: 24 x 5
path type size permissions modification_time
<fs::path> <fct> <fs::byte> <fs::perms> <dttm>
1 fr/LC_MESSAGES/graphics.mo file 12.19K rw- 2021-03-31 08:54:06
2 fr/LC_MESSAGES/grDevices.mo file 16.69K rw- 2021-03-31 08:54:06
3 fr/LC_MESSAGES/grid.mo file 2.78K rw- 2021-03-31 08:54:06
4 fr/LC_MESSAGES/methods.mo file 5.47K rw- 2021-03-31 08:54:06
5 fr/LC_MESSAGES/parallel.mo file 2.16K rw- 2021-03-31 08:54:06
6 fr/LC_MESSAGES/R-base.mo file 55.05K rw- 2021-03-31 08:54:06
7 fr/LC_MESSAGES/R-compiler.mo file 3.7K rw- 2021-03-31 08:54:06
8 fr/LC_MESSAGES/R-graphics.mo file 15.21K rw- 2021-03-31 08:54:06
9 fr/LC_MESSAGES/R-grDevices.~ file 13.37K rw- 2021-03-31 08:54:06
10 fr/LC_MESSAGES/R-grid.mo file 16.9K rw- 2021-03-31 08:54:06
11 fr/LC_MESSAGES/R-methods.mo file 68.69K rw- 2021-03-31 08:54:06
12 fr/LC_MESSAGES/R-parallel.mo file 3.86K rw- 2021-03-31 08:54:06
13 fr/LC_MESSAGES/R-splines.mo file 2.63K rw- 2021-03-31 08:54:06
14 fr/LC_MESSAGES/R-stats.mo file 85.47K rw- 2021-03-31 08:54:06
15 fr/LC_MESSAGES/R-stats4.mo file 1.36K rw- 2021-03-31 08:54:06
16 fr/LC_MESSAGES/R-tcltk.mo file 2.33K rw- 2021-03-31 08:54:06
17 fr/LC_MESSAGES/R-tools.mo file 42.34K rw- 2021-03-31 08:54:06
18 fr/LC_MESSAGES/R-utils.mo file 39.2K rw- 2021-03-31 08:54:06
19 fr/LC_MESSAGES/R.mo file 160.45K rw- 2021-03-31 08:54:06
20 fr/LC_MESSAGES/RGui.mo file 20.78K rw- 2021-03-31 08:54:06
21 fr/LC_MESSAGES/splines.mo file 582 rw- 2021-03-31 08:54:06
22 fr/LC_MESSAGES/stats.mo file 18.38K rw- 2021-03-31 08:54:06
23 fr/LC_MESSAGES/tcltk.mo file 1.37K rw- 2021-03-31 08:54:06
24 fr/LC_MESSAGES/tools.mo file 3.73K rw- 2021-03-31 08:54:06
I get the same results:
$ Rterm.exe --vanilla
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R est un logiciel libre livré sans AUCUNE GARANTIE.
Vous pouvez le redistribuer sous certaines conditions.
Tapez 'license()' ou 'licence()' pour plus de détails.
R est un projet collaboratif avec de nombreux contributeurs.
Tapez 'contributors()' pour plus d'information et
'citation()' pour la façon de le citer dans les publications.
Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide
en ligne ou 'help.start()' pour obtenir l'aide au format HTML.
Tapez 'q()' pour quitter R.
> local({
+ opwd <- setwd(file.path(R.home("library"), "translations"))
+ on.exit(setwd(opwd))
+ print(fs::dir_info(file.path("fr", "LC_MESSAGES"))[,1:5], n = Inf)
+ })
# A tibble: 24 x 5
path type size permissions modification_time
<fs::path> <fct> <fs::byte> <fs::perms> <dttm>
1 fr/LC_MESSAGES/graphics.mo file 12.19K rw- 2021-03-31 08:54:06
2 fr/LC_MESSAGES/grDevices.mo file 16.69K rw- 2021-03-31 08:54:06
3 fr/LC_MESSAGES/grid.mo file 2.78K rw- 2021-03-31 08:54:06
4 fr/LC_MESSAGES/methods.mo file 5.47K rw- 2021-03-31 08:54:06
5 fr/LC_MESSAGES/parallel.mo file 2.16K rw- 2021-03-31 08:54:06
6 fr/LC_MESSAGES/R-base.mo file 55.05K rw- 2021-03-31 08:54:06
7 fr/LC_MESSAGES/R-compiler.mo file 3.7K rw- 2021-03-31 08:54:06
8 fr/LC_MESSAGES/R-graphics.mo file 15.21K rw- 2021-03-31 08:54:06
9 fr/LC_MESSAGES/R-grDevices.~ file 13.37K rw- 2021-03-31 08:54:06
10 fr/LC_MESSAGES/R-grid.mo file 16.9K rw- 2021-03-31 08:54:06
11 fr/LC_MESSAGES/R-methods.mo file 68.69K rw- 2021-03-31 08:54:06
12 fr/LC_MESSAGES/R-parallel.mo file 3.86K rw- 2021-03-31 08:54:06
13 fr/LC_MESSAGES/R-splines.mo file 2.63K rw- 2021-03-31 08:54:06
14 fr/LC_MESSAGES/R-stats.mo file 85.47K rw- 2021-03-31 08:54:06
15 fr/LC_MESSAGES/R-stats4.mo file 1.36K rw- 2021-03-31 08:54:06
16 fr/LC_MESSAGES/R-tcltk.mo file 2.33K rw- 2021-03-31 08:54:06
17 fr/LC_MESSAGES/R-tools.mo file 42.34K rw- 2021-03-31 08:54:06
18 fr/LC_MESSAGES/R-utils.mo file 39.2K rw- 2021-03-31 08:54:06
19 fr/LC_MESSAGES/R.mo file 160.45K rw- 2021-03-31 08:54:06
20 fr/LC_MESSAGES/RGui.mo file 20.78K rw- 2021-03-31 08:54:06
21 fr/LC_MESSAGES/splines.mo file 582 rw- 2021-03-31 08:54:06
22 fr/LC_MESSAGES/stats.mo file 18.38K rw- 2021-03-31 08:54:06
23 fr/LC_MESSAGES/tcltk.mo file 1.37K rw- 2021-03-31 08:54:06
24 fr/LC_MESSAGES/tools.mo file 3.73K rw- 2021-03-31 08:54:06
Not sure if helps but still a thing. Here it only happens on RStudio, If I move to a terminal R it works as intended
Used the standard doc example:
library("R.utils")
foo <- function() {
print("Tic")
for (kk in 1:100) {
print(kk)
Sys.sleep(0.1)
}
print("Tac")
}
expr <- quote(foo())
res <- withTimeout(expr, substitute = FALSE,
timeout = 0.75, onTimeout = "warning")
SessionInfo:
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8 LC_CTYPE=Portuguese_Brazil.utf8
[3] LC_MONETARY=Portuguese_Brazil.utf8 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] R.utils_2.12.2 R.oo_1.25.0 R.methodsS3_1.8.2
loaded via a namespace (and not attached):
[1] compiler_4.2.1 tools_4.2.1
Hello,
Just to let you know that this is no longer an issue. The examples from my first comment now work as expected.
Looking at RStudio release notes, it seems to be related with RStudio version 2023.09.0: "Fixed issue where error messages were not properly translated on Windows in some cases (#10308)".
Hello,
The function
withTimeout
throws an error without considering the argumentonTimeout
(which can be"error"
,"warning"
or"silent"
).Here are simple examples:
After taking a look at how the function works, I noticed the use of the following instructions, which seems to be the issue:
In my R session, calls to
gettext
return French text whereas the functionsetTimeLimit
originally leads to an error written in English. This is why the search for matches usingregexpr
does not allow to find that the error is about a timeout.A simple fix would be to consider the default language used by R (which may be English) as well as the default user language (using
gettext
) as follows: