-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
I got the exact same issue as in #4550, but it's been closed and I cannot comment in it. This was with Linux with R 4.4.2 and my libraries up to date.
When using a minimal reproducible environment based on Guix, with just the R package and necessary R libraries, using Rscript script.R
or R --vanilla -e 'source("script.R")'
would run the script and even create directories where necessary (so no permission issues), but ggsave()
would produce the following warning (I think it should be an error, since it didn't create a file):
In grDevices::dev.off() : agg could not write to the given file
The error was not informative as to the actual cause, but I finally narrowed it down to one culprit: the absolute path of my working directory contained an acute diacritic. Somehow this did not prevent R from running and creating folders using ggsave(…, dir.create = TRUE)
, but the creation of the actual plot files was failing. It got resolved as soon as I removed the acute from the file hierarchy.
I am not sure if this is a ggsave()
issue or a Guix issue. I imagine both are possible: on the one hand, it might be a Guix bug related to locales missing in the Guix container I created, and running the script from my env instead of the container would fix that. On the other hand, it could also be that ggsave()
is unable to write files to paths containing diacritics even if R did not throw locale-related errors in the same condition.
If it's of any use, the data, scripts and Guix container to test which could be the cause are here: https://forgemia.inra.fr/mathieu.laparie/agrilusflight. If you think it's Guix, I'm happy to report this same issue to them.