CredibilityLab / groundhog

Reproducible R Scripts Via Date Controlled Installing & Loading of CRAN & Git Packages
https://groundhogr.com/
GNU General Public License v3.0
78 stars 4 forks source link

groundhog works only through Rstudio #74

Closed frederic-santos closed 2 years ago

frederic-santos commented 2 years ago

Hi, I've already noted on several GNU/Linux systems a strange behavior of {groundhog}. Let's take a fresh system, on which R has just been installed. As specified on the documentation, let's begin with:

install.packages("groundhog")
library("groundhog")

Everything's fine at this point. Then, let's try to install any R package by running the following into an R console:

groundhog.library("faraway", date = "2021-10-15")

I get the following error messages:

groundhog says:
The date you entered, '2021-10-15' requires updating your local database
with the list of all CRAN package-versions (cran.toc.rds)
essai de l'URL 'http://groundhogR.com/cran.times.rds'
Error in download.file(paste0(groundhogR.url, "cran.times.rds"), times.path,  :
  impossible d'ouvrir l'URL 'http://groundhogR.com/cran.times.rds'
De plus : Message d'avis :
Dans download.file(paste0(groundhogR.url, "cran.times.rds"), times.path,  :
  ouverture de l’URL 'http://groundhogR.com/cran.times.rds' impossible : le statut HTTP était '404 Not Found'
essai de l'URL 'http://groundhogR.com/cran.toc.rds'
Error in download.file(paste0(groundhogR.url, "cran.toc.rds"), toc.path,  :
  impossible d'ouvrir l'URL 'http://groundhogR.com/cran.toc.rds'
De plus : Message d'avis :
Dans download.file(paste0(groundhogR.url, "cran.toc.rds"), toc.path,  :
  ouverture de l’URL 'http://groundhogR.com/cran.toc.rds' impossible : le statut HTTP était '404 Not Found'
essai de l'URL 'http://groundhogR.com/missing.mran.dates.rds'
Error in download.file(paste0(groundhogR.url, "missing.mran.dates.rds"),  :
  impossible d'ouvrir l'URL 'http://groundhogR.com/missing.mran.dates.rds'
De plus : Message d'avis :
Dans download.file(paste0(groundhogR.url, "missing.mran.dates.rds"),  :
  ouverture de l’URL 'http://groundhogR.com/missing.mran.dates.rds' impossible : le statut HTTP était '404 Not Found'
Erreur dans gzfile(file, "rb") : impossible d'ouvrir la connexion
De plus : Message d'avis :
Dans gzfile(file, "rb") :
  impossible d'ouvrir le fichier compressé '/home/fsantos/R_groundhog/groundhog_library//cran.times.rds', cause probable : 'Aucun fichier ou dossier de ce type'

Strange thing: the exact same instruction works perfectly when it is executed through Rstudio. What is the cause for this behavior?

I have to say that I tried to change the option download.file.method to set it to any other allowed value (since Rstudio overwrites some R settings), and it did not bring any improvement.

Thanks!

(My setup: R 4.1.1, groundhog 1.5.0, running under Linux Manjaro.)

urisohn commented 2 years ago

If you run this in R outside of R Studio, do you get the same error msg? download.file("http://groundhogr.com/cran.toc.rds",your_path) (replacing the your_path for an actual path)

frederic-santos commented 2 years ago

Thanks for your answer!

Outside of Rstudio, I still get an error:

>  download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds")
essai de l'URL 'http://groundhogr.com/cran.toc.rds'
Erreur dans download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds") : 
  impossible d'ouvrir l'URL 'http://groundhogr.com/cran.toc.rds'
De plus : Message d'avis :
Dans download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds") :
  ouverture de l’URL 'http://groundhogr.com/cran.toc.rds' impossible : le statut HTTP était '404 Not Found'
urisohn commented 2 years ago

OK. I think this will work. Can you verify?

download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds", method='curl')

frederic-santos commented 2 years ago

It works! ;)

download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds", method='curl')
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20160    0 20160    0     0  29554      0 --:--:-- --:--:-- --:--:-- 29516
urisohn commented 2 years ago

Thanks. Actually, it is not really downloading it the full file. Will take a closer look,

urisohn commented 2 years ago

Ok, I think this should work.

download.file("http://groundhogr.com/cran.toc.rds", "~/Documents/test/cran.toc.rds", headers = c("User-Agent" = "groundhog_downloader"))

you should get a file >1.5 Mb downloaded

urisohn commented 2 years ago

Or, perhaps easier, you can test a version of groundhog that has this bug fixed (I think). install.packages("http://groundhogr.com/groundhog_1.5.0.9012.tar.gz",repos=NULL,type='source', method='libcurl')

I am about to submit version 1.6.0, and plan on including this fix if indeed it works

frederic-santos commented 2 years ago

Looks like everything works fine now! Thanks a lot!