This question has been asked in: Configure proxy on Rstudio. However, it was never resolved.
I am a user of RStudio 0.99.486 version and R 3.2.2 version. I have tried 2 ways to configure proxy settings in the office without success after reading several suggestions:
FIRST TRY:
Type in Rstudio as first line:
Sys.setenv(http_proxy="http://user_name:password#proxy.company_domain.es:8080/")
Go to:
-Tools, -Global Options, -Packages, and unmark option:
"Use internet library/proxy for HTTP"
I also unmarked the option: "Use secure download method for HTTP".
Besides, I right-clicked on the R x64 3.2.2 icon of the desktop and added after 1 space in the "Target" camp:
http_proxy=http://user_name:password#proxy.company_domain.es:8080/
It did not work as I received the message:
Warning in install.packages : cannot open: HTTP status was '407
Proxy Authentication Required'
SECOND TRY:
Create a notepad file with the name:
.Renviron
Saved it in: "C:\Users\username\Documents".
The file contains inside the following 2 lines:
http_proxy=http://proxy.company_domain.es/
http_proxy_user=user_name:password
When I try installing a package I receive:
"Warning in install.packages : unable to connect to
'cran.rstudio.com' on port 80.
Unable to access index for repository http://cran.rstudio.com/src/contrib"
After running code line: R.home() My R_HOME route is:
"C:/Program Files/R/R-32~1.2"
I appreciate before-hand for your advice and help.
Thank you for your question. It helped me to resolve my issue. I had to unmark the option to use the settings from the Internet Explorer and restart.
Maybe your .Renviron does not contain the proxy port, you have to write
http_proxy=http://proxy.company_domain.es:8080/
http_proxy_user=user_name:password
If you specify
http_proxy_user=ask
it should prompt you for user name and password - then you know that the file is read
I struggled with this when I initially started working behind a proxy. Here's what I believe is to be the solution. Disclaimer, I am working on a Windows 7 Workstation.
Even though when you read through the documentation, R suggests that .Renviron and .Rprofile should be in R.home(), that is not the case for Windows.
By default (I believe), the R.home() for Windows is actually the Documents folder for your user. You can check that with
path.expand("~/")
which defaults to "My Documents" directory.
Therefore, do place the .Renviron file with the content you
already have, disable the Internet Explorer option in RStudio, and
make sure you place the file in "My Documents."
Hope it helps!
I also nearly gave up on this problem until I found this simple solution (R3.3.1):
specify the system environment variables (in Windows Advanced System Settings add the variables http_proxy and https_proxy and set it to
http://user_name:password#proxy.company_domain.es:8080/ with your specific settings)
in the R console type
update.packages(ask='graphics',method="libcurl",checkBuilt=TRUE)
Related
I'm trying to update packages on RGui (64-bit) using update.packages but I'm getting the following message:
Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
'lib = "C:/PROGRA~1/R/R-212~1.1/library"' is not writable
Error in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
unable to install packages
I've looked at the library folder in Explorer and it has read only set, so I removed it. However, it reappears when I check the properties again immediately after doing this. Installing new packages is unaffected since they have a separate folder in my user profile.
Is there a trick to getting this to work?
It happens the same to me, and after coding hours and hours in "R" of Gui Project, i got bored because it is much easier to read a code when the interface uses colours for a certain type of words (commands). Well, i decided to install RStudio, but soon i was faced with package installation problems. It seems that happens in Windows 7. The way that I used to solve this problem with RSutido was:
C:\Program Files\R - and this is the folder that contains "R" and not RStudio folder!
Right click for properties.
Security.
In "Group or user names" select your name
click "Edit"
select "Full control"
Apply and click OK
After this steps you should be ok to install all the packages :-)
Usually you need administrator rights to change things in program files. Try running RGui as administrator.
try
install.packages('package_name', lib='folder')
you can specify a folder for installation of the libraries, for which you have writing permission.
Hope this helps
Uninstalling from C:\Program Files and re-installing to C:\R worked for me
[See mdsumner's comment and Windows FAQ found here]
"...Users of Vista/Windows 7/8/Server 2008/2012 installing for a single user using an account with administrator rights1 should consider installing into a non-system area (such as C:\R)"
I had this exact problem and just changed it for myself. That is I navigated to C:/PROGRAM/R and then right clicked on the R to bring up properties. Went to the Security tab clicked on the Group/User that you want to add permissions for. That for me was USER then clicked EDIT and then selected the boxes that were unchecked to Allow control over. I had to do this specifically for each user (of course I was running the entire time as administrator). Clicked Apply/OK and all is well. I can now update/install/ new libraries and what have you for this computer without having to run R as the admin.
Without more information, my first guess is that you have insufficient permissions to write to the R site library folder. Usually, R would prompt for creation of a user lib folder to install to, but this can be unreliable under Windows Vista/Windows 7.
Try:
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
In the R console. Libraries should now install to /Users/"you"/R/win-library/x.y, for which you have the appropriate permissions.
I have BitDefender 2018 and had to disable "safe files" and "firewall".
I had a similar error recently. Running RStudio as an administrator didn't work. And changing the permissions on C:/Programs/R is a bit clumsy, as you'd have to repeat it for every user.
The solution for me was changing the library path for R as follows
In the R console, type .libPaths(). You'll see something like this,
"Path/to/user/R/win-library/x.x" "C:/Programs/R/R-x.x.x"
The two paths exist because you have defined a user-specific lib path during installation. Replace x.x.x with your R version.
Now set the lib path to the Programs directory
.libPaths = "C:/Programs/R/R-x.x.x"
Now you can install.packages() or update.packages()!
Try choosing a cranmirror location closer to you with this command first
chooseCRANmirror()
And then try installing the package. This command worked for me when I was getting warnings on installing "devtools".
I also had this kind of problem in Windows 10, Then I disable "Safe Files" in Bitdefender 2018. It works for me
Sometimes there may also be a possibility that your Antivirus is blocking the application. Unblock the application if anti virus has blocked it.
I was wondering why it won't let me change my working directory.
I keep seeing this error:
Error in setwd(dataDir) : cannot change working directory
This is my code:
dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDir)
Seems to be an annoying Windows permissions issue; that's a legacy directory.
There are 2.93 million Google hits along the lines of "Windows (7/)10: Access to the path 'C:\Documents and Settings' is denied". Look for advice in Windows forums, and check what the ownership and permissions on "C:/Documents and Settings/My Documents/..." are currently, and what they're supposed to be, and whether Administrator account is enabled. (Frankly not the best choice for the R install packages directory, but many installers use it, or default to it.)
Please confirm that setwd() works fine for a more harmless choice of directory, e.g. 'C:\Users\your_name\R'
Are you running R as Administrator or User?
Did you install R as Administrator or User? (which installer did you use, and which installer version/date? R-project's? Anaconda? another?)
There must be an error in the path. It should look like C:\<your_username>\Documents and Settings\My Documents
Or try
setwd("C:\\[your_username]\\Documents and Settings\\My Documents\\R")
"Documents and Settings" is a directory that exists in really old versions of Windows (XP and earlier). In Windows 10, your user data is under C:\users\<username>, and your documents are in C:\users\<username>\Documents.
As far as R is concerned, under Windows 10 the home directory ~ maps to C:\users\<username>\Documents.
Run Rstudio as Admin.
then run dataDir <- "C:/Documents and Settings/My Documents/R/"
setwd(dataDirstrong text**)**
I'm working in RStudio and am attempting to install the dplyr package. I have installed various other packages without problem but have hit a problem with this.
It seems there are various parts to the install, some of these worked but the problem happens when I get 'the dependency BH'. This is the error:
>Installing package into ‘\\xxxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
also installing the dependency ‘BH’
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/BH_1.62.0-1.zip'
Content type 'application/zip' length 16150075 bytes (15.4 MB)
downloaded 15.4 MB
>trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/dplyr_0.5.0.zip'
Content type 'application/zip' length 2556205 bytes (2.4 MB)
downloaded 2.4 MB
>Error in install.packages : cannot open file '\\xxxxxxx.local/Desktops/jagnew/My Documents/R/win-library/3.3/file142032c9327b/BH/include/boost/function/detail/gen_maybe_include.pl': Permission denied
I have changed the directory/libpath as it did not appear that the file was downloading to the correct folder. file142032c9327b is now in the correct path, but path specified in the error is only correct up to /boost, there is no function folder here..?
I'm not sure if this missing folder is the issue, as the error says 'Permission denied', but it seems odd.
I had the same issue. Tried doing the following and worked for me:
Run the RStudio as administrator
Under the Packages tab, click Install and change Install to Library option to C:/Program...../R/../library and select the desired package to install.
Hope it works.
I had the same problem. R gave me an error message whenever I tried to install a new, or update an existing package. I don't remember what the message said exactly, but it was saying "Cannot open file (...) access denied". I tried all the following. Not sure what exactly fixed the problem, but now I can update and/or install new packages:
Open R/RStudio as administrator;
Change the R library folder (where packages are installed) security settings, and grant full access to my computer user account. Link1, link2;
(I think this was what fixed the problem) Follow instructions on this link. It prompted me to install another package, "devtools". Then it worked.
Well, I think my problem was a special case, but it might benefit someone. I had the Windows Defender Ransomware Protection set to ON. That was blocking rsession.exe by default. Allowing rsession.exe solved the problem.
TL;DR
The "Documents" (or "My Documents") directory is a special location in Windows. I don't know if the system itself processes its permissions differently or if antiviruses target operations inside this directory more strictly, but many R users have issues installing packages in the personal library inside this folder (even if running R as administrator). Other answers haven't worked.
For me, what solved the problem was to put the personal library directly under X:\\Users\username\ instead of under Documents, which is the R default on Windows. To make it permanent, I set a user environment variable R_USER to %USERPROFILE%. Here is a nice guide of how to set environment variables in Windows.
Note: after this change, you may need to move your .Rprofile, .Renviron, etc. files from Documents to the user profile directory.
Details
The default location for R's user "home" directory on Windows is X:\\Users\username\Documents. This is because there is no concept of HOME in Windows, just of a "personal" directory (Documents): https://cran.r-project.org/bin/windows/base/rw-FAQ.html#What-are-HOME-and-working-directories_003f
Therefore, by default, the personal library location is under X:\\Users\username\Documents\R\win-library\X.Y\. You can get the exact location on your machine with this command in the R console:
Sys.getenv('R_LIBS_USER')
I was getting this same cannot open file error when trying to install or update packages, even when running as administrator. I suspected of directory permissions, checked it within the directories' "properties" without luck. Removed the whole R\win-library tree and recreated it and nothing... Finally, I tried to move the personal library location to my users' directory:
.libPaths('X://Users/username/R/win-library/X.Y/')
And it worked!
Warning in install.packages :
cannot create file '/usr/local/Cellar/r/3.6.2/lib/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages :
cannot update HTML package index
I had the same permission issue when trying to download a pkg--ISLR. Fixed it after following the above answers.
In case, some are new to R studio like me. These were my steps to install a pkg.
Click Terminal next to Console in R studio
Type sudo r, to run r as an administrator
install.packages("ISLR") to install your package
--- Please select a CRAN mirror for use in this session ---
https://cran.rstudio.com/src/contrib/ISLR_1.2.tar.gz
Secure CRAN mirrors
1: 0-Cloud [https] 2: Australia (Canberra) [https]
3: Australia (Melbourne 1) [https] 4: Australia (Melbourne 2) [https]
Pick a number -- a mirror site, then click enter.
Voilà! Package installed.
I had faced also this issue. The one and only solution that helped me was to turn off my firewall. Then I was able to download all packages.
The problem solved for me after running R in admin mode and disabling Antivirus.
Translating #Shubham Yadav's answer to code mode would be something like this: install.packages("your_package", lib = "C:/Program Files/R/R-4.0.3/library")
It's working for me (running RStudio as admin, course).
This procedure worked for me.
Removed existing package with remove.packages()
ran RStudio as an admin
Installed by specifying the libpath: devtools::install_github('https://github.com/Rdatatable/data.table/tree/frollmax', lib=.libPaths()[2])
For me what worked was manually deleting within the library directory the folder that I had problem with updating. And then install.package() again.
I had faced the same issue.
I tried below steps to resolve this issue:
Launch RGui application.
Go to Packages section and select Install Packages.
Select the Package that you want to install from the Packages pop up window.
And click OK, that's it package will get successfully installed.
After following above steps, you can run use your package from RStudio.
I ran into this issue today where rlang couldn't install the newest version and so tidyverse wouldn't work. I tried running as admin, changing install location, running as admin, permitting rstudio through Windows Defender Randsomware Protection, and installing DevTools. The only thing that worked was to uninstall RStudio, reboot, reinstall.
I'm using a Windows 7 x64 machine with R-3.1.0. I installed the Rserve package through Rstudio.
The start of Rserve is successful with the following code in Rstudio:
library(Rserve)
Rserve()
I got the following output:
Starting Rserve...
"C:\R\R-31~1.0\library\Rserve\libs\x64\Rserve.exe"
My problem is that I couldn't locate the configuration file. Apparently it can't be "/etc/Rserv.conf".
I did come across a webpage saying that the config file is Rserv.cfg in the working directory (unless changed at compile-time). But which working directory? I have checked the working directory of the current R project as well as the Rserve library directory, but it was not there...Could someone help me with this please? Thank you.
Rserve does not automatically come with a config file, you must make one. Best steps for doing so:
Navigate to the file where you just installed Rserve.exe (C:\R\R-31~1.0\library\Rserve\libs\x64\R, based on the message you copied here)
Find Rserve.exe, Reserve_d.exe, and Rserve.dll there. Copy these files.
Navigate to where R.dll is on your computer. This is probably C:\Program Files\R\R-3.1.3\bin\x64, but may be different depending on where you installed R to.
Copy the 3 files mentioned above to this location.
Create a text file here named "Rserv.cfg" with the arguments you are looking for, such as port 6312 or library(mvoutlier). Yes, I know that this is different from the documentation, but if you start Rserve_d.exe you will see that this is the file it is looking for. I have not had success naming it anything else.
You can start Rserve by specifying the location of the config file. In R instead of just Rserve() try the following:
Rserve(args="--RS-conf C:\\folder\\Rserv.cfg")
If path is more complicated you need to massage it a little bit:
Rserve(args="--RS-conf C:\\PROGRA~1\\R\\R-215~1.2\\library\\Rserve\\Rserv.cfg")
Look in the $RHOME/bin directory
If you can't find it here is a different way to approach it:
Download Rserve at [http://rforge.net/snapshot/Rserve_.tar.gz], and save it in your desired directory
Run R CMD INSTALL Rserve_.tar.gz
This allows you to leave Rserve where you want it.
After looking at the Rserve source code and making some test I found that on Windows platform Rserve try to load the configuration file from the current working directory. Also pay attention because on Windows the file name is RServ.cfg and not Rserv.conf as documented.
The current working directory depends of the process, for example using RStudio by default it is your Documents and Settings folder:
C:\Users\[username]\Documents
but can be changed in the "Global Options" of the IDE
So you can create an "RServ.cfg" text file in that directory with your needed options and starting RServe in the usual way in RStudio
Rserve()
will load your configuration.
I'm trying to update packages on RGui (64-bit) using update.packages but I'm getting the following message:
Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
'lib = "C:/PROGRA~1/R/R-212~1.1/library"' is not writable
Error in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, :
unable to install packages
I've looked at the library folder in Explorer and it has read only set, so I removed it. However, it reappears when I check the properties again immediately after doing this. Installing new packages is unaffected since they have a separate folder in my user profile.
Is there a trick to getting this to work?
It happens the same to me, and after coding hours and hours in "R" of Gui Project, i got bored because it is much easier to read a code when the interface uses colours for a certain type of words (commands). Well, i decided to install RStudio, but soon i was faced with package installation problems. It seems that happens in Windows 7. The way that I used to solve this problem with RSutido was:
C:\Program Files\R - and this is the folder that contains "R" and not RStudio folder!
Right click for properties.
Security.
In "Group or user names" select your name
click "Edit"
select "Full control"
Apply and click OK
After this steps you should be ok to install all the packages :-)
Usually you need administrator rights to change things in program files. Try running RGui as administrator.
try
install.packages('package_name', lib='folder')
you can specify a folder for installation of the libraries, for which you have writing permission.
Hope this helps
Uninstalling from C:\Program Files and re-installing to C:\R worked for me
[See mdsumner's comment and Windows FAQ found here]
"...Users of Vista/Windows 7/8/Server 2008/2012 installing for a single user using an account with administrator rights1 should consider installing into a non-system area (such as C:\R)"
I had this exact problem and just changed it for myself. That is I navigated to C:/PROGRAM/R and then right clicked on the R to bring up properties. Went to the Security tab clicked on the Group/User that you want to add permissions for. That for me was USER then clicked EDIT and then selected the boxes that were unchecked to Allow control over. I had to do this specifically for each user (of course I was running the entire time as administrator). Clicked Apply/OK and all is well. I can now update/install/ new libraries and what have you for this computer without having to run R as the admin.
Without more information, my first guess is that you have insufficient permissions to write to the R site library folder. Usually, R would prompt for creation of a user lib folder to install to, but this can be unreliable under Windows Vista/Windows 7.
Try:
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE)
In the R console. Libraries should now install to /Users/"you"/R/win-library/x.y, for which you have the appropriate permissions.
I have BitDefender 2018 and had to disable "safe files" and "firewall".
I had a similar error recently. Running RStudio as an administrator didn't work. And changing the permissions on C:/Programs/R is a bit clumsy, as you'd have to repeat it for every user.
The solution for me was changing the library path for R as follows
In the R console, type .libPaths(). You'll see something like this,
"Path/to/user/R/win-library/x.x" "C:/Programs/R/R-x.x.x"
The two paths exist because you have defined a user-specific lib path during installation. Replace x.x.x with your R version.
Now set the lib path to the Programs directory
.libPaths = "C:/Programs/R/R-x.x.x"
Now you can install.packages() or update.packages()!
Try choosing a cranmirror location closer to you with this command first
chooseCRANmirror()
And then try installing the package. This command worked for me when I was getting warnings on installing "devtools".
I also had this kind of problem in Windows 10, Then I disable "Safe Files" in Bitdefender 2018. It works for me
Sometimes there may also be a possibility that your Antivirus is blocking the application. Unblock the application if anti virus has blocked it.