[R] Problems installing packages using the inbuilt facility: "Error i n gzfile(file, "r") : unable to open connection"
Kauer, Philipp
philipp.kauer at credit-suisse.com
Mon Mar 10 10:41:09 CET 2008
Thank you Henrik for your response.
As I indicated at the end of my e-mail, I only have this problem at work, and was not be able to replicate it at home (ie packages load fine there). I followed the steps you suggested, but unfortunately no luck (below is the output). Essentially, the error messages are the same to the one shown in my initial e-mail.
I noticed that Bob Green posted a very similar request on Friday, when he had problems performing 'update packages' on a new install of 2.6.2 on Windows XP, and it was suggested that some things in the startup directories were not working. After some further investigation, I noticed that various packages that I instruct to load in my site Rprofile(I am upgrading from an older version of R), were not loading properly either, and after removing them, AND using the --internet2 option, the problem disappeared.
To recap for anyone else who is experiencing a similar problem: Try starting R with the option --internet2 (to get rid of any problems with -open.connection(con, "r") : unable to resolve 'cran.r-project.org' etc), and remove any packages in the site and local Rprofile, which do not load properly (that seemed to fix the problems experienced with gzfile).
Regards - Philipp
> url = "http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip"
> download.file(url, basename(url), mode="wb")
trying URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip'
Error in download.file(url, basename(url), mode = "wb") :
cannot open URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip'
In addition: Warning message:
In download.file(url, basename(url), mode = "wb") :
unable to resolve 'cran.uk.r-project.org'
> file.info(basename(url))
size isdir mode mtime ctime atime exe
ada_2.0-1.zip 0 FALSE 666 2008-03-10 08:31:16 2008-03-10 08:20:53 2008-03-10 08:20:53 no
> install.packages(basename(url), repos=NULL)
Error in gzfile(file, "r") : unable to open connection
In addition: Warning messages:
1: In zip.unpack(pkg, tmpDir) : error 1 in extracting from zip file
2: In gzfile(file, "r") :
cannot open compressed file 'ada/DESCRIPTION', probable reason 'No such file or directory'
-----Original Message-----
From: henrik.bengtsson at gmail.com [mailto:henrik.bengtsson at gmail.com] On Behalf Of Henrik Bengtsson
Sent: 07 March 2008 23:47
To: Kauer, Philipp
Cc: r-help at lists.R-project.org
Subject: Re: [R] Problems installing packages using the inbuilt facility: "Error i n gzfile(file, "r") : unable to open connection"
Works fine for me on the same setup. Try this and compare (especially the size of the downloaded file):
> url <-
> "http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip";
> download.file(url, basename(url), mode="wb") # Note "wb"!!!
trying URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip'
Content type 'application/zip' length 971893 bytes (949 Kb) opened URL downloaded 949 Kb
> file.info(basename(url))
size isdir mode mtime ctime
ada_2.0-1.zip 971893 FALSE 666 2008-03-07 15:43:52 2008-03-07 15:43:28
atime exe
ada_2.0-1.zip 2008-03-07 15:43:52 no
> install.packages(basename(url), repos=NULL)
package 'ada' successfully unpacked and MD5 sums checked updating HTML package descriptions
> library(ada)
Loading required package: rpart
>
/Henrik
On Fri, Mar 7, 2008 at 10:02 AM, Kauer, Philipp <philipp.kauer at credit-suisse.com> wrote:
> Hi
>
> I have been trawling the web, FAQs, and R manuals for help on the following issue, but have failed and was wondering if anyone has a solution to the following problem:
>
> After having installed R 2.6.2 for Windows (binary), I tried to install various packages. Every time I try loading a package (any package) via the built-in menu, I run into the following error message.
>
> > utils:::menuInstallPkgs()
> trying URL 'http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip <http://cran.uk.r-project.org/bin/windows/contrib/2.6/ada_2.0-1.zip> '
> Content type 'application/zip' length 971893 bytes (949 Kb) opened
> URL downloaded 949 Kb
>
> Warning in gzfile(file, "r") :
> cannot open compressed file 'ada/DESCRIPTION', probable reason 'No such file or directory'
> Error in gzfile(file, "r") : unable to open connection > traceback()
> 6: gzfile(file, "r")
> 5: read.dcf(file.path(curPkg, "DESCRIPTION"), c("Package", "Version",
> "Type"))
> 4: unpackPkg(foundpkgs[okp, 2], foundpkgs[okp, 1], lib,
> installWithVers)
> 3: .install.winbinary(pkgs = pkgs, lib = lib, contriburl = contriburl,
> method = method, available = available, destdir = destdir,
> installWithVers = installWithVers, dependencies = dependencies)
> 2: install.packages(NULL, .libPaths()[1], dependencies = NA, type =
> type)
> 1: utils:::menuInstallPkgs()
>
> I tried saving the ZIP of the package to my C drive, and then installing from that, but I get the same error message. I then tried calling gzfile with the filename of the ZIP directly, and I seem to get a file handle without any error message:
>
> gzfile("C:/Program Files/R/R-2.6.2/library/ada_2.0-1.zip","r")
> description class
> "C:/Program Files/R/R-2.6.2/library/ada_2.0-1.zip" "gzfile"
> mode text
> "rb6" "binary"
> opened can read
> "opened" "yes"
> can write
> "no"
>
>
>
> It might be worth noting, that I initially I also had problems with the internet download facility, which I fixed starting R with the flag --internet2, as indicated in the FAQs.
>
> Can you please help?
>
> Many thanks - Philipp
>
> PS: I did the same on my PC at home, and there everything works without problems.
>
>
>
> ======================================================================
> ======== Please access the attached hyperlink for an important
> el...{{dropped:8}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
==============================================================================
Please access the attached hyperlink for an important el...{{dropped:5}}
More information about the R-help
mailing list