Error: Permission Denied when changing preference Rstudio - r

Whenever I try to change the global setting (preferences) of Rstudio (for example unchecking the box that restores .Rdata into workspace upon startup as part of general options) and click 'apply' or 'ok', I receive
"Error: Permission denied" and the changes were not made
(The error messages comes up regardless what change I make in the preferences). How, where and what kind of permission do I need to grant?
I have delete and re-installed R studio but the error messages keeps coming up. I am also running Rstudio as admin with read&write privileges.
I've seen the post on the Rstudio community (https://community.rstudio.com/t/error-permission-denied-when-settings-are-changed/88178) but I don't find the solution helpful.
R version 4.0.4 (2021-02-15) macOS Big Sur Version 11.5.2

It's because Rstudio saves its preference in the ~\.config folder which it do not have the permission to write.
You can change the permission of .config folder to solve.
sudo chown -R <username> .config
<username> should be replaced by your username. And you can run whoami command to check it out.

Related

Setting a working directory: "Error in setwd: cannot change working directory" under "C:/Documents and Settings/..."

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**)**

Rstudio server cannot find correct location of R installation (ubuntu)

I have R 3.4.0 installed to /home/ubuntu/software/R/R-3.4.0/bin, which is a 'non-standard' install location. I then installed rstudio server, and edited the rserver.conf file to include: rsession-which-r=/home/ubuntu/software/R/R-3.4.0/bin
I thought this would be sufficient. At ip:8787 the rstudio server login box appears, and I can login, but then get an error that no session was found.
I also tried adding to the rserver.conf file:
rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin
but this failed to even load the rstudio login page at ip:8787. After removing this line I now cannot even get back to the login page.
What is going wrong here? Linux has been a nightmare for me, it's been missing file after missing file error, EVEN after I blatantly set LD env variables to the correct paths (via LD_config, make.config files AND configuration files). I feel like I'm missing something fundamental here.
What is the correct command to install R to Rstudio's expected path, if there's no sane way to tell rstudio-server it's in a non-standard path? I used:
./configure --prefix=/home/ubuntu/software/R/R-3.4.0 --with-x=yes --enable-R-shlib=yes --with-cairo=yes
make
to install.
Additional info:
cat /var/log/user.log | grep rstudio
- nothing
cat /var/log/syslog | grep rstudio
- many errors, first: ERROR R did not return any output when queried for directory location information
sudo rstudio-server verify-installation
- ERROR R script path (/home/ubuntu/software/R/R-3.4.0/bin) is a directory rather than a file
Issue was with
`rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin`
The rconfig file needs to point to a file (not dir), should be:
rsession-ld-library-path=/home/ubuntu/software/R/R-3.4.0/bin‌​/R

run R as administrator

I was using my own laptop to install R and I found that it only has one library. Evne though this library is still read only, everytime when I use Rstudio: install.packages("abc"), I can see that the new packages are stored automatically into that read only library folder.
In my office's desktop, I "believe" I also have administrator role, as I can install and remove anything (by far). I download the latest version of R and I right click the R-3.4.1-win.exe, there is an item "run as administrator", then it is installed in my desktop. However, when I use R studio to install new packages as in my laptop, it always automatically create a personal folder to store the new packages. I don't know why. Is that a way to only have one folder for library? I also tried on the desktop in the plain R mode (without using Rstudio). When I want to install new packages, it always says
Warning in install.packages("devtools") :
'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable
And there is a window pops up to ask me "would you like to create a personal folder?" And if I say no, then
Error in install.packages("devtools") : unable to install packages.
Is there a ways to solve this problem? To just maintain one folder for library
What version of Windows are you using? You should be able to right-click on the Rstudio.exe icon, click Properties, and select an option to always run Rstudio as administrator. Be sure you use that same icon whenever you want to open Rstudio.
Incase of Mac, go to Applications, then right click on RStudio and
Select "Show Package Contents"
Go to Contents/MacOS
Now open terminal(in bash mode). Type sudo and drag the RStudio.exec into terminal and press on ENTER
Now RStudio will have admin access!
For completeness, I think there should be an Ubuntu answer to go along with the Microsoft and Apple answers. (Note:I'm using 18.06, and not 20.x.)
What doesn't work:
On my Ubuntu/Linux system, when Rstudio is installed the call start RStudio from a terminal looks something like the following:
(base) username#sysname:~$ rstudio
It starts, but has the permissions of the user, and can have access errors.
What gives admin power:
To give it better permissions, you can use sudo.
(base) username#sysname:~$ sudo rstudio
[sudo] password for username: <enter password here>
It starts in a different user location, but has more power. After it is installed you can run it the regular way and the packages are still installed.
Extra credit:
Here are some (currently) relevant links for RStudio on Ubuntu:
https://linuxhint.com/rstudio-for-ubuntu/
https://www.r-bloggers.com/2013/03/download-and-install-r-in-ubuntu/
What is the command to invoke RStudio from Command Line in linux environment?
http://web.cs.ucla.edu/~gulzar/rstudio/index.html

RStudio Server returns "Cannot read property 'error' of null"

When I try to go into RStudio Server (1.0.44), I get the following error in the browser:
RStudio Initialization Error
(TypeError) : Cannot read property 'error' of null
This happens before logging in - it has the rotating clock thing for a minute and goes straight into that.
I have tried all sorts of remedies, including restarting the server, rebooting, uninstalling and reinstalling RStudio server, changing the port settings, deleting the .RStudio folder in my home directory, etc. I checked the system log and that didn't seem to have anything relevant. There were a few errors, of course, but nothing after I got the error.
Also, R works fine from the terminal and I have the latest version of both R and RStudio.
Anyone have any ideas?
You probably tried to restart rstudio already, but this is not enough.Follow these steps:
Do a ps -u user where user is one of the user whose session is returning the error in the browser
[root]# ps -u username
PID TTY TIME CMD
19445 ? 00:00:18 rsession
kill the rsession related to it using it's PID.
[root]# kill 19445
start rstudio using sudo rstudio-server start.
Go to the folder contained within the project you were working with last and delete the ProjectName.Rproj file.
restart rstudio using sudo rstudio-server restart
P.S:
If after second step, problem remains, you could remove the .Rproj file using command line: rm directory/of/Rproj/File/ProjectName.Rproj
rm -r .rstudio
sudo rstudio-server suspend-all
worked for me.
I first also moved .RData to a separate folder and upgraded the rstudio server. However, still the problem remained.
I went through a lot of trouble and have finally managed to get it to work again. What ultimately seems to have worked is upgrading to the newest version (1.0.136), deleting all .Rhistory and .Rproj.user files, stopping the server and deleting the .rstudio file in my user profile, and then restarting. I wish I had more info on why it stopped and what fixed it exactly, but at least it's working again. Note that when I upgraded--and before deleting the .rstudio folder (which I had already done a few times), the error message changed to:
Status code 500 returned
So that seems to be the same error--maybe this will help someone else to resolve this problem.

RStudio gives "Incorrect function" when setting git as Version control

When I create a new project and select to create a new Git repository, or when I try to change the version control system in project options I receive a RStudio error stating "Incorrect function" with a big X and no extra information.
The below link has a similar issue, but their solution of changing the path for git.exe has not helped (i have tried all three paths)
https://support.rstudio.com/hc/en-us/community/posts/200632528-Git-Error-Incorrect-Function
Some extra notes:
RStudio allows me to clone repository to set new working directory
Also git works in bash, so i feel this is an RStudio issue.
I encountered the same error. For me it also had to do with using a network path not a local directory for the project location (as for lewis1211).
Workaround: Map the network drive. E.g. Map your //server/share to some drive, say Z: (using map network drive, if you are using windows). If you set your project up under Z: then, it works.
If you have already chosen "git.exe" in RStudio --> Tools --> Global Options --> Git/SVN, then try to open Rstudio shell and type git init. In my case it showed "Permission denied", and after running as administrator the problem has gone.
This is only a partial answer if it fixes your problem: I reproduced this when trying to use a network path for a project location. When using a local directory no error occurs. Could indeed be an RStudio issue.
Run you R studio as Project administration.
This solves my issue.
SOLVED.
I had the same problem. The Git-RStudio-Connection fails but git is working perfectly in the CMD. When running the git init command in CMD it works and creates a .git folder. But running the git init command in the RStudio terminal fails with a message Warning: unable to access 'C:/Users/%username%/.gitconfig': Permission denied ... fatal: unknown error occured while reading the configuration files.
The Version Control Sytem (VCS) or git-Panel does not appear in RStudio and selecting it in the projects options leads to the same message Error: Unzulässige Function (eng. Error: Incorrect function).
A closer look into the .gitconfig file should give you a new solution approach hopefully without having administration rights. Comparing the installation on the integration worksation with a productive workstation shows, that on the Test-Machine an incomplete .gitconfig file is on C:/Users/%username%/.gitconfig and on the Productive-Machine a complete gitconfig file is on Z:/.gitconfig. By the way, Z is a mapped drive which is linking to the company's user-profile settings (see CMD > echo %HOMEDRIVE%).
According to this analysis there should be multiple possible solution approaches:
(1) delete the corrupt .gitconfig and hope the the system is correctly looking into your profiles directory
(2) complete the .gitconfig file that all necessary information are there. The message fatal: unknown error occured while reading the configuration files could actually be a hint, that the first message access... permission denied is false and the problem lies in the incomplete file.
(3) Be aware that there can be a confusion between ".gitconfig" as FILE and ".gitconfig" as FOLDER. Check this with changing directory with cd to folder and cat to show the file content. It will tell you that you cannot display a folder as file-content.
(4) Change the location of the config file with git config --file FullnameToGitconfig. e.g. git config --file %USERPROFILE%/.gitconfig or git config --file %USERPROFILE%/.gitconfig/gitconfig or git config --file %HOMEDRIVE%/.gitconfig etc.
[user]
name = DOE John
email = john.doe#acme.com
[merge]
tool = kdiff3
[mergetool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[diff]
guitool = kdiff3
[difftool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
[core]
editor = \"C:/Program Files (x86)/GitExtensions/GitExtensions.exe\" fileeditor

Resources