Feature #868

Updated by Sebastien Jacquot almost 6 years ago

R cannot access internet if there is a proxy:
* during TXM installation (Linux + Mac OS X) -> R configuration
* during the "Check R packages" command. -> Rserve & R configuration

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)

*Setup: solution1* :
* Embed R in all setups and provide the exact libraries for this version of R -> solve R packages installation but not "Check R packages" command

*Setup: solution2*:
* Windows: run R with "--internet2" argument
* Debian/Ubuntu: R automatically uses the "http_proxy" which is normally generated by the network manager. It means there is nothing more to do than running R et install the packages as with direct connection. But we may still test if "http_proxy" exists and do "something" if the variable doesn't exist because the tests have only been made on Ubuntu.
* Mac OS X Mavericks: Network manager does not create "http_proxy" environment variable so we need to create it once. The proxies settings can be retrieved using "networksetup -getwebproxy <Network service>" then we can create the variable before running R with "export" or in R with Sys.setenv().

[SJ] It appears there is no easy cross-platform solution therefore the solution 1 seems to be the better one.

For TXM RCP we need to define if we want that R uses the operating system proxy/network configuration or the Eclipse RCP proxy/network configuration.
[SJ] I think the better feature would be to match the R network configuration to the Eclipse RCP network configuration. But it may be complex to implement, for example, changing the "Networking configuration" in RCP would run some R command as Sys.setenv("http_proxy=http://proxy.xxxxx.com").

*TXM RCP: solution 1* :
Do not match the RCP configuration but the OS configuration
* Windows: see Setup: solution 1
* Debian/Ubuntu: see Setup: solution 1
* Mac OS X Mavericks: see Setup: solution 1

*TXM RCP: solution 2* :
Match the R network configuration with the RCP network configuration
* add some proxy properties in TBX (http_proxy, http_port, http_user, http_password)
* at RCP startup load these preferences into TBX preferences before running R/RServe

At R first run:
* Windows: run R with: R http_proxy="http_user:http_password@http_proxy:http_port" or create the variable before running R: set http_proxy="http_user:http_password@http_proxy:http_port". (Sys.setenv() doesn't seems to work for this under Windows XP)
* Linux/Mac: use a shell command as: export http_proxy="http_user:http_password@http_proxy:http_port" or in R: R Sys.setenv(http_proxy="http_user:http_password@http_proxy:http_port")

At RCP network configuration 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")

*Setup/TXM RCP: solution 3* :
* see R options download.file.method = "wget" or "lynx" or install.packages(method = "wget"). wget seems to use the OS network configuration rather than the R network configuration.
The problem is under Mac OS X and Windows "wget" is not installed by default.

*Setup/TXM RCP: solution 4* :
* use .RProfile or .Renviron files to configure the R network

NOTE: Linux "export" and Windows "set" command create the variable in the local session scope, they are not permanently stored.