How to install package when HTTP status was '404 Not Found'

10,261

Solution 1

Seems that repository at http://cran.ma.imperial.ac.uk is messed up. There is fields_6.9.1.tgz (you could check it by going to http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz), but in PACKAGES file (which is used by install.packages to find url of package) there is:

Package: fields
Version: 7.1
Title: Tools for spatial data
Depends: R (>= 3.0), methods, spam, maps
Built: R 3.1.0; x86_64-apple-darwin13.1.0; 2014-05-20 04:58:37 UTC; unix
Archs: fields.so.dSYM

That is why you got 404 error.

If you want to install by hand you need to either download file and install from local file or use

# cran got 7.1
packageurl <- "http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz"
# your mirror got 6.9.1
packageurl <- "http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz"
library(devtools)
install_url(packageurl)

I think this is temporary problem and in some point in time proper file will show up.


Now you can do it with base R:

CHANGES IN R 3.1.1
NEW FEATURES

  • install.packages(repos = NULL) now accepts http:// or ftp:// URLs of package archives as well as file paths, and will download as required. In most cases repos = NULL can be deduced from the extension of the URL.

Solution 2

I had this issue after installing R 3.4.0 for Win 10, 64-bit. Was unable to resolve it, so I rolled back to 3.3.3 and now it works fine again.

Before doing this, I tried deleting the RStudio user settings and the R package library (if the problem was caused by a broken package).

Solution 3

I had the same issue when updated to R 3.4.1 on mac Sierra. The problem fixed when I changed the CRAN mirror in the preferences/packages

Share:
10,261
user1320502
Author by

user1320502

Updated on June 12, 2022

Comments

  • user1320502
    user1320502 almost 2 years

    I am having a rather tough time with the fields package.

    sessioninfo()
    R version 3.1.0 (2014-04-10)
    Platform: x86_64-apple-darwin13.1.0 (64-bit)
    
    locale:
    [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base    
    

    form the url everything seems to be fine and fields depends on > or = to 3.0

    I have tried downloading the package with install.packages but I get a rather strange result i have not seen before:

    trying URL 'http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz'
    Error in download.file(url, destfile, method, mode = "wb", ...) : 
      cannot open URL 'http://cran.ma.imperial.ac.uk/bin/macosx/mavericks/contrib/3.1/fields_7.1.tgz'
    In addition: Warning message:
    In download.file(url, destfile, method, mode = "wb", ...) :
      cannot open: HTTP status was '404 Not Found'
    Warning in download.packages(pkgs, destdir = tmpd, available = available,  :
      download of package ‘fields’ failed
    

    I have also tried downloading using the url for the files directly for both 7.1 and 6.9.1(mavericks):

    packageurl <- "http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz"
    > install.packages(packageurl, contriburl=NULL, type="source")
    Warning message:
    package ‘http://cran.r-project.org/bin/macosx/mavericks/contrib/3.1/fields_6.9.1.tgz’ is not available (for R version 3.1.0) 
    
    > packageurl <- "http://cran.r-project.org/bin/macosx/contrib/3.1/fields_7.1.tgz"
    > install.packages(packageurl, contriburl=NULL, type="source")
    Warning message:
    package ‘http://cran.r-project.org/bin/macosx/contrib/3.1/fields_7.1.tgz’ is not available (for R version 3.1.0) 
    

    and running all the .R files from the unpacked .tar file

    sapply(list.files(pattern="[.]R$", path="........fields/R/", full.names=TRUE), source)
    

    but if I do this then functions do not work e.g.

    > rdist(c(1,1))
    Error in .Fortran("radbas", PACKAGE = "fields", nd = as.integer(d), x1 = as.double(x1),  : 
      "radbas" not available for .Fortran() for package "fields"
    

    QUESTION - This seems weird that fields is not available for R 3.1 as it is an intensely used package by many, any ideas on solving this?

  • Marek
    Marek almost 10 years
    @user1320502 Thank Hadley for that :D There is lot of cool stuff in that package.
  • JACKY88
    JACKY88 about 7 years
    I have the same problem but it seems the packages can still be installed even though this warning message shows up.
  • jb123
    jb123 about 7 years
    I have this problem, too, but installing the package with R instead of RStudio still works.
  • Seanosapien
    Seanosapien almost 7 years
    I had this same issue with a Windows OS recently. I just used R instead of R Studio to install Rcpp and everything was fine too.
  • Djork
    Djork almost 7 years
    @jb123 solution above of installing with R instead of RStudio also worked for me in MacOS (Sierra)