Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in file(con, "r") : cannot open the connection in new R 3.2.1 install #35

Closed
rjbeilstein opened this Issue Jul 10, 2015 · 25 comments

Comments

Projects
None yet
@rjbeilstein
Copy link

rjbeilstein commented Jul 10, 2015

I just installed a squeaky clean R 3.2.1 on a new Windows 7 system. Was able to load installr using install.packages. Was able to load it using library(installr), and got the expected messages.

When I actually try to run one of the subprograms, however, (updateR, install.RStudio, etc.) all I get is the above message.

I have done several Google searches and found very little. One entry suggested uninstalling RGui and reinstalling from the website. I've done that also. I'm quickly running out of ideas...

Here's a sample session:

R version 3.2.1 (2015-06-18) -- "World-Famous Astronaut"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: i386-w64-mingw32/i386 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

library(installr)

Welcome to installr version 0.16.0

More information is available on the installr project website:
https://github.com/talgalili/installr/

Contact: tal.galili@gmail.com
Suggestions and bug-reports can be submitted at: https://github.com/talgalili/installr/issues

                    To suppress this message use:
                    suppressPackageStartupMessages(library(installr))

install.RStudio()
Error in file(con, "r") : cannot open the connection
updateR()
Error in file(con, "r") : cannot open the connection

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Jul 10, 2015

Two things to tru,

  1. Run:
    setInternet2(TRUE)

  2. Try to run R in administrator mode.
    http://windows.microsoft.com/en-us/windows7/how-do-i-run-an-application-once-with-a-full-administrator-access-token

Tell me if it works :)

@rjbeilstein

This comment has been minimized.

Copy link
Author

rjbeilstein commented Jul 10, 2015

Running R as an administrator didn't help.

However, setInternet2(TRUE) did!!!

THANK YOU!

      /Bob
@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Jul 10, 2015

Great, I'm glad it helped 👍

@drasnop

This comment has been minimized.

Copy link

drasnop commented Jul 12, 2015

I had the same problem on Windows 8.1. setInternet2(TRUE) fixed it.
Since it is a pretty puzzling error, and Google doesn't help, I'd suggest adding the solution to the Troubleshooting section of the Readme.

@rjbeilstein

This comment has been minimized.

Copy link
Author

rjbeilstein commented Jul 13, 2015

I agree. This one was weird, and I am hardly a novice at troubleshooting. I spent hours looking at Windows logs, reinstalling R, etc., before giving up and just asking. I actually even read the README! ;-)

talgalili added a commit that referenced this issue Jul 13, 2015

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Jul 13, 2015

Thanks @drasnop and @rjbeilstein - I've now added this to the README file.

@glensmith1

This comment has been minimized.

Copy link

glensmith1 commented Jul 18, 2015

Trying to update my older version of R, R version 3.2.0 (2015-04-16) -- "Full of Ingredients"
to latest.

setInternet2(TRUE) still returns error

library(installr)

Welcome to installr version 0.16.1

More information is available on the installr project website:
https://github.com/talgalili/installr/

Contact: tal.galili@gmail.com
Suggestions and bug-reports can be submitted at: https://github.com/talgalili/installr/issues

                    To suppress this message use:
                    suppressPackageStartupMessages(library(installr))

setInternet2(TRUE)
updateR()
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
InternetOpenUrl failed: 'The connection with the server was reset'

I am using an old Vista OS

@FionaScu

This comment has been minimized.

Copy link

FionaScu commented Jul 28, 2015

I am on Vista OS and neither Running R as an administrator or setInternet2(TRUE) worked

updateR()
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
InternetOpenUrl failed: 'The connection with the server was reset'

@tbs08

This comment has been minimized.

Copy link

tbs08 commented Aug 8, 2015

i second the solution of setInternet2(TRUE). it does work!

@alexcphung

This comment has been minimized.

Copy link

alexcphung commented Aug 28, 2015

After using setInternet2(TRUE) , I got the R-3.2.2-win.exe is not a valid Win32 application. Anyone can help ?

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Aug 28, 2015

@alexcphung - no idea. Such a thing is best asked on R-help mailing list or stackoverflow.com

@sharmi0013

This comment has been minimized.

Copy link

sharmi0013 commented Jul 4, 2016

@talgalili ..Two thumbs up for the setInternet2(TRUE) solution! Thanks a ton! It worked!!

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Jul 4, 2016

@sharmi0013 my pleasure.

@vkobayashi

This comment has been minimized.

Copy link

vkobayashi commented Sep 3, 2016

setInternet2(TRUE) worked! thanks.

-- Windows 7 machine user

@86smopuiM

This comment has been minimized.

Copy link

86smopuiM commented Sep 21, 2016

setInternet2(TRUE) did not work for me. Windows 8.1. Run as admin did nothing either.

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Sep 21, 2016

@86smopuiM what is your sessionInfo() ?

@86smopuiM

This comment has been minimized.

Copy link

86smopuiM commented Sep 21, 2016

setInternet2(TRUE)
installr()
Error in file(con, "r") : for https:// URLs use setInternet2(TRUE)
sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United
States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C

[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] installr_0.17.8

loaded via a namespace (and not attached):
[1] rsconnect_0.4.3 tools_3.1.3

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Sep 21, 2016

Thanks. o.k.,
Fixing this would probably mean updating the package to use curl, which I'm not likely to do this month. But I am going to reopen this - so I'll get to it in the future.

@talgalili talgalili reopened this Sep 21, 2016

@20GT

This comment has been minimized.

Copy link

20GT commented Dec 23, 2016

OS: Windows 8.1
I'm unable to bring the text of the file into working memory in R as an object. instructions at http://www.electrostani.com/2015/10/syuzhet-sentiment-analysis-of-novels.html

https://s19.postimg.org/untfwcb2b/2016_12_17_11_53_10_RStudio.png

get_text_as_string("C:\a\asleep")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file 'C: sleep': Invalid argument

I moved the file to a folder in E: still no good

get_text_as_string("E:\a\asleep")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file 'E: sleep': Invalid argument

I moved the file directly to E: and renamed it to sleep still no good

get_text_as_string("E:\sleep")
Error: '\s' is an unrecognized escape in character string starting ""E:\s"

E:\sleep
Error: unexpected input in "E:"
get_text_as_string("E:\a\asleep")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file 'E:\a�sleep': Invalid argument
setInternet2(TRUE)
Error in setInternet2(TRUE) : use != NA is defunct

Any sugestions?

@ssalimi

This comment has been minimized.

Copy link

ssalimi commented Jun 11, 2017

Hello,
Using Windows 10 , Rstudio,

MQ<-read.table(file="Desktop/MQ.RESHAPE7/", header=TRUE, sep=",")

I get the same message
In addition: Warning message:
In file(file, "rt") :
cannot open file 'Desktop/MQ.RESHAPE7/': No such file or directory

and
setInternet2(TRUE) did NOT work. Any advice?
Thanks

@torarnesen

This comment has been minimized.

Copy link

torarnesen commented Mar 23, 2018

Hello,

got the same problem here - Win 10 64 bit, updating Rstudio to Version 1.1.442 produce the error "In file(con, "r") : cannot open file ...etc"

@hafez-ahmad

This comment has been minimized.

Copy link

hafez-ahmad commented Mar 27, 2018

read.csv(url("https://github.com/Robinlovelace/Creating-maps-in-R/blob/master/data/census-historic-population-borough.csv"))
Error in open.connection(file, "rt") : cannot open the connection
In addition: Warning message:
In open.connection(file, "rt") :
InternetOpenUrl failed: 'An error occurred in the secure channel support'

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Mar 28, 2018

@hafez-ahmad how is this related to installr?

@tyw0115

This comment has been minimized.

Copy link

tyw0115 commented Apr 2, 2018

hello, I am using Win 10 64 bit, I am trying to install ImageMagic by installr. But I went through this:

> install.ImageMagick()
> Error in file(con, "r") : cannot open the connection
> > setInternet2(TRUE)
> Error: 'setInternet2' is defunct.
> See help("Defunct")

which means setinternet2 had been removed? So what should I do with the" can not open the connection" error? Thank you very much.

@talgalili

This comment has been minimized.

Copy link
Owner

talgalili commented Apr 10, 2018

Thanks, this is fixed in the version on github:

if (!require('devtools')) install.packages('devtools'); # make sure you have Rtools installed first! if not, then run:
#install.packages('installr')
#install.Rtools()
devtools::install_github('talgalili/installr')

I'll hopefully get it to CRAN in the next couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.