Solve Your Install Packages Problem Error in R Studio
While I am starting my journey in a programming language with R and Python, I face several newbie problems that I need to solve for me to be able to learn correctly. One of my very first problems is the "install packages error" in R Studio. My first attempt using > install.packages ("...") command is to install the "ggplot2" package, and it is, in fact, running smoothly.
Warning in install.packages:'lib="C:/Users/myaccount/OneDrive/Document/R/win-library/4.1" 'is not writeable.
No matter which procedure I used to install it, whether through command in Console, install packages in Tools tab, or install in Packages tab. It's all the same. Sometimes, when I force R studio to choose an alternate folder to install my packages, it will start installing and downloading them. Like it usually processes the command. But then again, in the end, two different messages appear on my Console saying:
Warning in install.packages: cannot create dir 'C:\Users\myaccount\OneDrive\Document\R\win-library\4.1\file2d9c17c720b3', reason 'No such file or directory'
Error in install.packages: unable to create temporary directory 'C:\Users\myaccount\OneDrive\Document\R\win-library\4.1\file2d9c17c720b3'.
Principally there are four options out there for you to try. But at first, you have to understand your main problem. Based on the error messages, you might think there is a permission problem that prevents R Studio from accessing your file directory.
Warning in install.packages: 'lib="C:/Users/myaccount/OneDrive/Document/R/win-library/4.1" 'is not writeable.
In the error message above, R Studio wants to download and install your packages to a directory in C:/Users/myaccount/OneDrive/Document/R/win-library/4.1, but somehow, R does not has permission to do it.
We often see these issues with someone running R on a network and having a shared network disk that they store things on, but that doesn't seem to be the case here. I am using R on my own, I am not sharing my network, and no parties are involved. If your case is similar to mine, one thing we could try is verifying that this directory hasn't been closed for some reason.
Here's a plenty guide to set permissions for a directory on Windows:
- Your first option to try is to check if you may forget to run R as an administrator. It could be the source of the problems. If it is, try to re-run R as administrator. Right-click on the file and choose the Run as administrator option. Nevertheless, you could also use R Studio to fix it. Click Terminal next to Console in R studio. Type "sudo r" to run R as an administrator. Then try again to install your package as usual.
- If the first solution made no difference, then try the second option. You could set your file and folder access permission. You as users or R as an application might not have permission to access the folder. It explains why the directory is not writeable. Every file or folder in Windows has its own set of permissions, and Permissions can be broken down into Access Control Lists with users and their corresponding rights. Generally, in Windows, every file or folder gets its permissions from the parent folder. You can access these permissions by right-clicking on a file or folder, choosing Properties, and clicking on the Security tab. To edit permissions for a particular user, click on that user and click the Edit button. For further details about the steps to obtain permission, please check this article below:
- Still, get stuck? Here you go, the third option. As you may notice, sometimes, when we need to install or update an application on our computer, we have to turn off our antivirus program first to be able to run it. In my case, the third option is the solution. Perhaps, my problem was a particular case. My Windows Defender Ransomware Protection is on and blocking rsession.exe by default. Authorizing rsession.exe solved the problem. You could check if /path/R.exe is included in Windows Ransomware Protection. Get path from the file.path(R.home("bin"), "R"), or simply just turn off your Windows Defender Ransomware protection in the virus & protection setting. It applies to any other antivirus program out there (Avast, McAfee, etc.).
- Lastly, if you are in a good mood, change your directory / libPaths. Why do you have to be in a good mood? Because it is a little bit need more effort. Please check this link for further details of the step: r - installing package - cannot open file - permission denied
Komentar
Posting Komentar