TBX: X.X, R proxy configuration during TXM work session
R cannot access internet if there is a proxy during the “Check R packages” command. ->Rserve & R configuration
Hypothesis1
R proxy configuration depends on the Operating System:
- Windows: R uses the “—internet2” option
- Mac OS X/Linux: R uses the “http_proxy” environment variable
- For Windows: the “—internet2” option can be added automatically. see: http://cran.r-project.org/bin/windows/base/rw-FAQ.html#The-Internet-download-functions-fail_002e
- For Mac OS X and Linux, we have to test the “http_proxy” R env variable is used
Currently R and RServe options are not configured by TXM StatEngine
preferences.
(For runtime proxy options see also commands: setInternet2(use=TRUE) and
Sys.setenv(http_proxy=“http://user:password@proxy.example.com:8080/”
))
(We may also use .Rprofile system ? MD: I would rather not do this)
Solution 0
Use .RProfile or .Renviron files to configure the R network.
Solution 1
Match the R network configuration with the OS network configuration
Retrieve the OS proxy configuration: HOW TO (for each OS)
At TXM start up:
- Windows:
- run R with: R http_proxy=“http_user:http_password@http_proxy:http_port”
- create the variable before running R: set http_proxy=“http_user:http_password@http_proxy:http_port”
- or use the R command line: Sys.setenv(…). But it doesn’t seem to work for this with Windows XP
- Linux/Mac:
- use a shell command as: export http_proxy=“http_user:http_password@http_proxy:http_port”
- or use the R command line: Sys.setenv(http_proxy=“http_user:http_password@http_proxy:http_port”)
Solution 2
Match the R network configuration with the RCP network configuration.
Retrieve the RCP proxy configuration:
http://blog.vogella.com/2009/12/08/eclipse-rcp-proxy-preference/
At TXM start up: see Solution 1
Optionnaly, update R proxy when RCP preferences change:
- Windows: no good solution at this moment (actually one would be to restart R with: R http_proxy=“http_user:http_password@http_proxy:http_port”) (Sys.setenv() doesn’t seems to work for this under Windows XP)
- Linux/Mac: call in R: Sys.setenv(http_proxy=“http_user:http_password@http_proxy:http_port”)
Solution 3
Use OS download method instead of the R native download method. The OS download method uses the OS network configuration rather than the R network configuration.
- in R :
- set the “download.file.method” R option
- or use the “method” parameter of the “install.packages” function : install.packages(.., method = “wget”)
- The download method depends on the OS :
- Linux: wget
- Mac OS X : curl
- Windows : no need to install packages
NOTE: Linux “export” and Windows “set” command create the variable in the local session scope, they are not permanently stored.
Validation tests
- run TXM with a proxy connection
- enable all log levels in preferences and enable “Run RServe in debug mode”
- restart TXM
- run a .R file containing
install.packages("textometry", dependencies=TRUE, repos="http://cran.rstudio.com/");
=>in the console you should have some entries like this:
Rserve>Calling R_tryEval for expression 1 [type=6] ...
Rserve>Installing package into 'C:/Users/s/TXM/R/libraries'
Rserve>(as 'lib' is unspecified)
Rserve>trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/textometry_0.1.4.zip'
Rserve>Content type 'application/zip' length 38040 bytes (37 Kb)
Rserve>opened URL
Rserve>downloaded 37 Kb
Rserve>
Rserve>package 'textometry' successfully unpacked and MD5 sums checked
Rserve>
Rserve>The downloaded binary packages are in
Rserve> C:\Users\s\AppData\Local\Temp\RtmpCOyMKe\downloaded_packages
- the test has failed if you have this line in the console instead of the above log:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib
(from redmine: issue id 868, created on 2014/06/17 by Matthieu Decorde)
- Relations:
- relates #525 (closed)
- relates #857
- parent #1022 (closed)