goldingn / versions

Query and Install Specific Versions of Packages on CRAN
Other
24 stars 7 forks source link

No support for packages without archives #7

Closed MarcinKosinski closed 8 years ago

MarcinKosinski commented 8 years ago

devtools devtools::install_version(package = 'assertthat', version = '0.1') can easily download assertthat package from it's only version where versions::install.versions('assertthat', versions = '0.1') gives warning

Error in if (!df$available[idx]) { : 
  missing value where TRUE/FALSE needed

probably due to the NA values in result of this

$assertthat
  version date available
1     0.1 <NA>        NA

Is this a bug or a feature?

MarcinKosinski commented 8 years ago

In case you've missed that @goldingn

goldingn commented 8 years ago

Hi @MarcinKosinski,

TL;DR: I can't replicate this error in versions 0.2 (posted recently). Using version 0.1 I get a similar but different error. Can you let me know whether you were using 0.1 or 0.2 and whether the issue persists?


Using versions 0.2 I get:

versions::install.versions('assertthat', versions = '0.1')
Error in version2date(pkgs = pkgs, versions = versions) : 
  0.1 is a valid version of assertthat, but was published before
                  2014-09-17 and can therefore not be downloaded from MRAN.
                  Try using devtools::install_version to install the package
                  from its source in the CRAN archives 

Which is the expected behaviour (as I'm sure you know versions depends on binaries from MRAN).

It looks like something changed between our two attempts though, since I get:

versions::available.versions('assertthat')
$assertthat
  version       date available
1     0.1 2013-12-05     FALSE

Given it's an old package, I suspect nothing much has changed on MRAN (though there could have been a temporary blip during their snapshot-taking?).

I had suspected this relates to issue #5 which I fixed in version 0.2 (pushed to GitHub and CRAN a couple of weeks ago), but using 0.1 I get a different error message:

versions::install.versions('assertthat', versions = '0.1')
curl: (22) The requested URL returned error: 404 Not Found
Error in url.lines(url) : 
  URL does not appear to exist: https://mran.revolutionanalytics.com/snapshot/2016-02-28/src/contrib/Archive/assertthat

Which version are you using and do you still get the error?

MarcinKosinski commented 8 years ago

I am using version 0.2 but maybe it relates to my repos Option?

> library(versions)
> devtools::session_info()
Session info --------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.2 (2015-08-14)
 system   x86_64, linux-gnu           
 ui       RStudio (0.99.879)          
 language English                     
 collate  pl_PL.UTF-8                 
 tz       <NA>                        
 date     2016-02-29                  

Packages ------------------------------------------------------------------------------------------------------------
 package    * version    date       source        
 archivist  * 2.0.1      2016-02-24 CRAN (R 3.2.2)
 assertthat   0.1        2013-12-06 CRAN (R 3.2.2)
 bitops       1.0-6      2013-08-17 CRAN (R 3.2.0)
 colorspace   1.2-6      2015-03-11 CRAN (R 3.2.2)
 DBI          0.3.1      2014-09-24 CRAN (R 3.2.2)
 devtools     1.9.1      2015-09-11 url (/@)      
 digest       0.6.9      2016-01-08 CRAN (R 3.2.2)
 dplyr      * 0.4.3      2015-09-01 CRAN (R 3.2.2)
 ggplot2    * 2.0.0      2015-12-18 CRAN (R 3.2.2)
 ggthemes   * 3.0.2      2016-02-26 CRAN (R 3.2.2)
 gtable       0.2.0      2016-02-26 CRAN (R 3.2.2)
 httr         1.1.0      2016-01-28 CRAN (R 3.2.2)
 lubridate    1.5.0      2015-12-03 CRAN (R 3.2.2)
 magrittr     1.5        2014-11-22 CRAN (R 3.2.0)
 memoise      1.0.0      2016-01-29 CRAN (R 3.2.2)
 munsell      0.4.3      2016-02-13 CRAN (R 3.2.2)
 plyr         1.8.3      2015-06-12 CRAN (R 3.2.1)
 R6           2.1.2      2016-01-26 CRAN (R 3.2.2)
 Rcpp         0.12.3     2016-01-10 CRAN (R 3.2.2)
 RCurl        1.95-4.7   2015-06-30 CRAN (R 3.2.1)
 RSQLite      1.0.0      2014-10-25 CRAN (R 3.2.1)
 scales       0.4.0      2016-02-26 CRAN (R 3.2.2)
 stringi      1.0-1      2015-10-22 CRAN (R 3.2.1)
 stringr      1.0.0      2015-04-30 CRAN (R 3.2.0)
 survival   * 2.38-3     2015-07-02 CRAN (R 3.2.1)
 survminer  * 0.2.0.9002 2016-02-28 local         
 versions   * 0.2        2016-02-17 CRAN (R 3.2.2)
> versions::install.versions('assertthat', versions = '0.1')
Error in if (!df$available[idx]) { : 
  missing value where TRUE/FALSE needed
> ?versions::install.versions
> getOption("repos")
                       CRAN 
"https://cran.rstudio.com/" 
attr(,"RStudio")
[1] TRUE
goldingn commented 8 years ago

Hmmm, weird.

I also have:

getOption("repos")
                      CRAN 
"https://cran.rstudio.com" 

It's hard for me to tell without a failing example, but looks like this all boils down to an error in the web-scraping* done in the unexported versions::current.version()

I have a hunch it may be related to your unset time zone - what does Sys.Date() return for you right now?

Could you also try re-running your code in a fresh R session in case it's an interaction with one of the other packages you have loaded?


*versions deliberately uses regex rather than e.g. rvest to keep the package dependency-free, a requirement for another project that relies on this

goldingn commented 8 years ago

My session info, FYI:

devtools::session_info()
Session info-------------------------------------------------------------------
 setting  value
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, darwin15.2.0
 ui       unknown
 language (EN)
 collate  en_AU.UTF-8
 tz       Australia/Melbourne

Packages-----------------------------------------------------------------------
 package    * version date       source
 devtools     1.6.1   2014-10-07 CRAN (R 3.2.3)
 rstudioapi   0.1     2014-03-27 CRAN (R 3.2.3)
library(versions)
devtools::session_info()
Session info-------------------------------------------------------------------
 setting  value
 version  R version 3.2.3 (2015-12-10)
 system   x86_64, darwin15.2.0
 ui       unknown
 language (EN)
 collate  en_AU.UTF-8
 tz       Australia/Melbourne

Packages-----------------------------------------------------------------------
 package    * version date       source
 devtools     1.6.1   2014-10-07 CRAN (R 3.2.3)
 rstudioapi   0.1     2014-03-27 CRAN (R 3.2.3)
 versions   * 0.2     2016-02-17 CRAN (R 3.2.3)
MarcinKosinski commented 8 years ago

I Have tried this and got an error on 2 various machines: Windows and ubuntu.

Every time one uses regex to parse HTML, a small panda in china cries. I'd rather suggest using rvest/xml2.

I'll keeep checking the time zone in the evening.

Marcin Kosinski

Dnia 29.02.2016 o godz. 01:32 Nick Golding notifications@github.com napisał(a):

Hmmm, weird.

I also have:

getOption("repos") CRAN "https://cran.rstudio.com" It's hard for me to tell without a failing example, but looks like this all boils down to an error in the web-scraping* done in the unexported versions::current.version()

I have a hunch it may be related to your unset time zone - what does Sys.Date() return for you right now?

Could you also try re-running your code in a fresh R session in case it's an interaction with one of the other packages you have loaded?

*versions deliberately uses regex rather than e.g. rvest to keep the package dependency-free, a requirement for another project that relies on this

— Reply to this email directly or view it on GitHub.

MarcinKosinski commented 8 years ago
> install.packages('versions')
Installing package into ‘C:/Users/Marcin/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/versions_0.2.zip'
Content type 'application/zip' length 24737 bytes (24 KB)
downloaded 24 KB

package ‘versions’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\Marcin\AppData\Local\Temp\RtmpOUi9Bc\downloaded_packages
> library(versions)
> devtools::install_version(package = 'assertthat', version = '0.1')
Installing package into ‘C:/Users/Marcin/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) : 
  cannot open URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  cannot open URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip': HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘assertthat’ failed
> Sys.Date()
[1] "2016-03-01"
> as.POSIXct(Sys.Date())
[1] "2016-03-01 01:00:00 CET"
> Sys.time()
[1] "2016-03-01 23:47:44 CET"
goldingn commented 8 years ago

So devtools is failing now too?

MarcinKosinski commented 8 years ago

Yes, on my WINDOWS it does not work for any of devtools or versions


> install.packages('versions')
Installing package into ‘C:/Users/Marcin/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/versions_0.2.zip
'
Content type 'application/zip' length 24737 bytes (24 KB)
downloaded 24 KB

package ‘versions’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\Marcin\AppData\Local\Temp\Rtmp61TbX4\downloaded_packages
> library(versions)
> versions::install.versions(pkg = 'assertthat', versions = '0.1')
Error in if (!df$available[idx]) { :
  missing value where TRUE/FALSE needed
>
> devtools::install_version('assertthat', '0.1')
Installing package into ‘C:/Users/Marcin/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip'
Error in download.file(url, destfile, method, mode = "wb", ...) :
  cannot open URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip'
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
  cannot open URL 'http://cran.rstudio.com/src/contrib/assertthat_0.1.zip':
HTTP status was '404 Not Found'
Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
  download of package ‘assertthat’ failed

Under ubuntu it works only for devtools

2016-03-01 23:53 GMT+01:00 Nick Golding notifications@github.com:

So devtools is failing now too?

— Reply to this email directly or view it on GitHub https://github.com/goldingn/versions/issues/7#issuecomment-190947679.

goldingn commented 8 years ago

OK got it. Thanks for testing on both machines and posting all this output! Will keep hunting and seeing if I can replicate the error somehow.

goldingn commented 8 years ago

I have an ubuntu machine in the UK, running on a similar timezone to you and the same version of R. I installed versions 0.2 from CRAN and ran this in a fresh session:

versions::install.versions(pkg = 'assertthat', versions = '0.1')
Error in version2date(pkgs = pkgs, versions = versions) :
  0.1 is a valid version of assertthat, but was published before
                  2014-09-17 and can therefore not be downloaded from MRAN.
                  Try using devtools::install_version to install the package
                  from its source in the CRAN archives
devtools::session_info()
Session info -------------------------------------------------------------------
 setting  value
 version  R version 3.2.2 (2015-08-14)
 system   x86_64, linux-gnu
 ui       X11
 language en_US:
 collate  en_US.UTF-8
 tz       <NA>
 date     2016-03-01

Packages -----------------------------------------------------------------------
 package  * version date       source
 devtools   1.9.1   2015-09-11 CRAN (R 3.2.2)
 digest     0.6.8   2014-12-31 CRAN (R 3.2.0)
 memoise    0.2.1   2014-04-22 CRAN (R 3.2.0)
 versions   0.2     2016-02-17 CRAN (R 3.2.2)
goldingn commented 8 years ago

@MarcinKosinski, I now suspect (though this is still guesswork) that this may be an encoding issue and that readLines is guessing a different encoding for the MRAN on my machines than yours.

I've created a new branch with the encoding set as UTF-8. You should be able to install it with:

devtools::install_github('goldingn/versions@encoding_experiments')

You can make sure you have the right one installed by looking the readLines call in:

versions:::url.lines
function (url) 
{
    file <- tempfile()
    suppressWarnings(success <- download.file(url, file, quiet = TRUE))
    if (success != 0) {
        stop(sprintf("URL does not appear to exist: %s", url))
    }
    lines <- readLines(file, encoding = "UTF-8")
    file.remove(file)
    return(lines)
}
<environment: namespace:versions>

I then still get the expected response on my machines:

versions::install.versions(pkgs = 'assertthat', versions = '0.1')
Error in version2date(pkgs = pkgs, versions = versions) : 
  0.1 is a valid version of assertthat, but was published before
                  2014-09-17 and can therefore not be downloaded from MRAN.
                  Try using devtools::install_version to install the package
                  from its source in the CRAN archives

Would you mind trying this on your ubuntu box?

Sorry I still can't replicate this error at my end

MarcinKosinski commented 8 years ago

Ok I'll Try to use that.

Marcin Kosinski

Dnia 02.03.2016 o godz. 01:27 Nick Golding notifications@github.com napisał(a):

@MarcinKosinski, I now suspect (though this is still guesswork) that this may be an encoding issue and that readLines is guessing a different encoding for the MRAN on my machines than yours.

I've created a new branch with the encoding set as UTF-8. You should be able to install it with:

devtools::install_github('goldingn/versions@encoding_experiments') You can make sure you have the right one installed by looking the readLines call in:

versions:::url.lines function (url) { file <- tempfile() suppressWarnings(success <- download.file(url, file, quiet = TRUE)) if (success != 0) { stop(sprintf("URL does not appear to exist: %s", url)) } lines <- readLines(file, encoding = "UTF-8") file.remove(file) return(lines) }

I then still get the expected response on my machines: versions::install.versions(pkgs = 'assertthat', versions = '0.1') Error in version2date(pkgs = pkgs, versions = versions) : 0.1 is a valid version of assertthat, but was published before 2014-09-17 and can therefore not be downloaded from MRAN. Try using devtools::install_version to install the package from its source in the CRAN archives Would you mind trying this on your ubuntu box? Sorry I still can't replicate this error at my end — Reply to this email directly or view it on GitHub.
goldingn commented 8 years ago

Closing this as I can't replicate and it seems non urgent. Let me know if you'd like me to repoen it though!

MarcinKosinski commented 8 years ago

Yes, I think I used different package.

stla commented 7 years ago

Hello, Similar problem (on Windows). Solved as follows.

# save the current locale
lct <- Sys.getlocale("LC_TIME") 
# set the C locale
Sys.setlocale("LC_TIME", "C")
# this works now
available.versions("checkpoint")
# restore the locale
Sys.setlocale("LC_TIME", lct)

The problem occurs in the function versions:::current.version.

goldingn commented 7 years ago

Ah, that's really helpful, thanks!

I'll try to work up a failing example and a fix

stla commented 7 years ago

@goldingn Hello. FYI, I firstly observed the NA's generated by versions:::current.version. Then I found the fix in ?as.Date:

## read in date info in format 'ddmmmyyyy'
## This will give NA(s) in some locales; setting the C locale
## as in the commented lines will overcome this on most systems.
## lct <- Sys.getlocale("LC_TIME"); Sys.setlocale("LC_TIME", "C")
x <- c("1jan1960", "2jan1960", "31mar1960", "30jul1960")
z <- as.Date(x, "%d%b%Y")
## Sys.setlocale("LC_TIME", lct)
z
goldingn commented 7 years ago

Thanks @stla, that makes a lot of sense ! I can't replicate as I don't have a windows machine, but I've just pushed a branch which should fix this and any other date issues caused by the same locale conflict.

Would you mind confirming that it works for you on Windows? You can do: devtools::install_github('goldingn/versions@set_locale')

stla commented 7 years ago

Hello @goldingn. Sorry the installation does not work for me:

> devtools::install_github('goldingn/versions@set_locale')
Downloading GitHub repo goldingn/versions@set_locale
from URL https://api.github.com/repos/goldingn/versions/zipball/set_locale
Installing versions
Error in read.dcf(file = tmpf) : cannot open the connection
stla commented 7 years ago

@goldingn I've managed to install by downloading the zip. But available.versions does not work, as before.

stla commented 7 years ago

No sorry in fact the installation has not worked... I still have the previous version.

goldingn commented 7 years ago

OK, thanks.

That's strange, that code works fine for me to install it, and I just tried installing it on a colleague's Windows machine and had no problems.

It looks like it downloads fine, but then loses track of the tempfile. Could you try this maybe ?:

install.packages('remotes')
remotes::install_github('goldingn/versions@set_locale')

Otherwise, if you have more info on why your installation from zip failed, I could take a look at that. Thanks for your time & sorry it's being awkward!