Closed
Description
System details
RStudio Edition : <!-- Desktop or Server -->
RStudio Version : Version 1.0.136
OS Version : ubuntu
R Version : 3.3.3
Steps to reproduce the problem
plot(cars)
Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) In addition: Warning message: In grDevices:::png("/tmp/RtmpEdEj7l/642098b8481c4db7820081c92f4117e7.png", : unable to open connection to X11 display ''
| >
Describe the problem in detail
i am trying to run plot(cars) on rstudio application ,receiving this below error
plot(cars)
Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) In addition: Warning message: In grDevices:::png("/tmp/RtmpEdEj7l/642098b8481c4db7820081c92f4117e7.png", : unable to open connection to X11 display ''
| >
Activity
ronblum commentedon Feb 19, 2018
@ArRstudio Are you able to run
plot(cars)
successfully in R alone, outside of RStudio? Also, you might consider updating to the latest version of RStudio, 1.1.423, which is available for download at https://www.rstudio.com/products/rstudio/download/ronblum commentedon Feb 20, 2018
@ArRstudio It looks like this is being handled by our professional Support Team (issue 25469) so I'm am going to close it in this queue.
Andreas-Bio commentedon Feb 25, 2019
Same issue here:
Another RStudio instance works but this instance fails.
Rietaros commentedon May 7, 2019
I use RStudio Version 1.1.463 – © 2009-2018 RStudio, Windows 10
have the same issue
Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) In addition: Warning messages: 1: In grDevices:::png("C:/Users/AFITRI~1/AppData/Local/Temp/RtmpQBGjX0/01f79ba1aad74fd3b5c52d0423bda7af.png", : unable to open file 'C:/Users/AFITRI~1/AppData/Local/Temp/RtmpQBGjX0/01f79ba1aad74fd3b5c52d0423bda7af.png' for writing 2: In grDevices:::png("C:/Users/AFITRI~1/AppData/Local/Temp/RtmpQBGjX0/01f79ba1aad74fd3b5c52d0423bda7af.png", : opening device failed
kevinushey commentedon May 20, 2019
The error most likely implies that RStudio / your user account does not have write access to your Temp folder for some reason. Unfortunately figuring out why this is the case could be very challenging.
werner-rammer commentedon Apr 2, 2020
I experienced the same error; thanks for @kevinushey for hinting at missing write access!
I am on Windows, and for some reason the temp directory RStudio was trying to write into did not exist anymore (my RStudio is already open for quite a long time).
The problem was gone and plotting back to normal when I recreated the temp folder (in my case the
c:/users/xxx/AppData/Local/Temp/Rtmp0kHPQi
folder).10515524 commentedon Apr 21, 2020
@werner-rammer
I recreated the temp folder and it worked. Thank you!
ytrancer commentedon Apr 23, 2020
The last folder in the path did not exist. Re-creating the folder has solved the issue for me.
kevinushey commentedon Apr 23, 2020
If I understand correctly, this issue is occurring because something is deleting the R temporary directory in your session? AFAIK this shouldn't happen normally, but we could try to recover by auto-recreating the directory as needed...
ytrancer commentedon Apr 23, 2020
Sometimes I will start a project and, when I have a break, I will just close the laptop lid. Maybe temp files are erased as Windows goes into standby.
werner-rammer commentedon Apr 23, 2020
@kevinushey : yes, re-creating the folder if missing would solve the issue. It does not always happen when Windows goes into standby, and my guess is that it is related to Windows updates (but really just a guess).
By the way: QGis has a very similiar issue (saving of a project fails when the temp directory is gone).
25 remaining items
valerie-rstudio commentedon Jun 23, 2021
QA Note
I am currently unable to reproduce this issue.
mikebessuille commentedon Jun 28, 2021
This has not been reproed internally, and Kevin believes this is a problem in R, not RStudio. Closing this issue.
qingjian1991 commentedon Jul 22, 2021
Thanks, this works for me
tanjialing commentedon Jul 29, 2021
thank you very much!it worked!
alexandramarcos1896 commentedon Aug 2, 2021
It works for me. Thank u
MJimitater commentedon Feb 7, 2022
@werner-rammer How did you re-create the tmp folder please? Delete it and re-run command that lets it re-create it?
werner-rammer commentedon Feb 7, 2022
Well, the error message refers to a directory which does not exist anymore. Go the the folder, create a directory with the name given by the error message, and run the R code again. This worked for me on Windows.
rwitkowski3 commentedon Jan 29, 2024
This worked!