Skip to content

Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) #2214

Closed
@ArRstudio

Description

@ArRstudio

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 ''

 

| >

Describe the behavior you expected

Activity

ronblum

ronblum commented on Feb 19, 2018

@ronblum
Contributor

@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/

added
info neededAdditional information requested—reprex, steps, open question, etc.
on Feb 19, 2018
ronblum

ronblum commented on Feb 20, 2018

@ronblum
Contributor

@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

Andreas-Bio commented on Feb 25, 2019

@Andreas-Bio

Same issue here:


> plot(mtcars)
Error in RStudioGD() : 
  Shadow graphics device error: r error 4 (R code execution error)
In addition: Warning messages:
1: In grDevices:::png("C:/Users/gf1954/AppData/Local/Temp/Rtmp02Ep26/1033921b18d7481796b9759f3bc1e62b.png",  :
  kann Datei 'C:/Users/gf1954/AppData/Local/Temp/Rtmp02Ep26/1033921b18d7481796b9759f3bc1e62b.png' nicht zum Schreiben öffnen
2: In grDevices:::png("C:/Users/gf1954/AppData/Local/Temp/Rtmp02Ep26/1033921b18d7481796b9759f3bc1e62b.png",  :
  opening device failed

Another RStudio instance works but this instance fails.

Rietaros

Rietaros commented on May 7, 2019

@Rietaros

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

kevinushey commented on May 20, 2019

@kevinushey
Contributor

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

werner-rammer commented on Apr 2, 2020

@werner-rammer

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

10515524 commented on Apr 21, 2020

@10515524

@werner-rammer
I recreated the temp folder and it worked. Thank you!

ytrancer

ytrancer commented on Apr 23, 2020

@ytrancer

The last folder in the path did not exist. Re-creating the folder has solved the issue for me.

kevinushey

kevinushey commented on Apr 23, 2020

@kevinushey
Contributor

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

ytrancer commented on Apr 23, 2020

@ytrancer

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

werner-rammer commented on Apr 23, 2020

@werner-rammer

@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

valerie-rstudio commented on Jun 23, 2021

@valerie-rstudio

QA Note

I am currently unable to reproduce this issue.

removed this from the 1.6 (Q4 2021) milestone on Jun 28, 2021
mikebessuille

mikebessuille commented on Jun 28, 2021

@mikebessuille
Contributor

This has not been reproed internally, and Kevin believes this is a problem in R, not RStudio. Closing this issue.

qingjian1991

qingjian1991 commented on Jul 22, 2021

@qingjian1991

Under the Tools menu is the Global Options... command that lets you set the graphics backend (under the General section, Graphics tab). Changing the graphics device backend to "Cairo" made this error go away for me.

Thanks, this works for me

tanjialing

tanjialing commented on Jul 29, 2021

@tanjialing

The fix for this, #6722, should be in the 1.4 Wax Begonia dailies. Note, though, that the dailies are meant for testing purposes only.

thank you very much!it worked!

alexandramarcos1896

alexandramarcos1896 commented on Aug 2, 2021

@alexandramarcos1896

Rtmp0kHPQi

It works for me. Thank u

MJimitater

MJimitater commented on Feb 7, 2022

@MJimitater

@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

werner-rammer commented on Feb 7, 2022

@werner-rammer

@werner-rammer How did you re-create the tmp folder please? Delete it and re-run command that lets it re-create it?

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

rwitkowski3 commented on Jan 29, 2024

@rwitkowski3

Under the Tools menu is the Global Options... command that lets you set the graphics backend (under the General section, Graphics tab). Changing the graphics device backend to "Cairo" made this error go away for me.

This worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @OfekShilon@jmcphers@kevinushey@DawnEve@enbrown

    Issue actions

      Error in RStudioGD() : Shadow graphics device error: r error 4 (R code execution error) · Issue #2214 · rstudio/rstudio