Skip to content

export/save as image/r code execution error #3166

Closed

Description

@uwemenzel

System details

RStudio Edition : Desktop
RStudio Version : 1.1.453
OS Version      : Windows 10
R Version       : 3.5.0

Steps to reproduce the problem

In the plot window:
Export
Save as image
png (or other)
Save

Describe the problem in detail

"R code execution error"
If I try saving "manually"

dev.copy(png, file = "uab.png"); dev.off()
Error in device(...) : unable to start png() device
In addition: Warning messages:
1: In device(...) : unable to open file 'uab.png' for writing
2: In device(...) : opening device failed

It works if I use the usual Windows R console.
So it's definitely an R-Studio problem.

Describe the behavior you expected

I expected that saving a plot would save the plot to disk

Activity

  1. ronblum commented on Jul 17, 2018

    @ronblum
    Contributor

    @uwemenzel Can you please provide a reproducible example? For example, does executing

    plot(cars)
    

    from the console and saving with the default parameters reproduce the issue?

  2. added
    info needed
    on Jul 17, 2018
  3. Jiachen-Ma-code commented on Oct 14, 2019

    @Jiachen-Ma-code

    I got the same issue from RStudio.

  4. ronblum commented on Oct 15, 2019

    @ronblum
    Contributor

    @Rabbita What environment are you using—specifically, RStudio version, R version, and operating system?

  5. Jiachen-Ma-code commented on Oct 16, 2019

    @Jiachen-Ma-code

    R Studio Version 1.2.1335,
    R:
    platform x86_64-w64-mingw32
    arch x86_64
    os mingw32
    system x86_64, mingw32
    status
    major 3
    minor 6.1
    year 2019
    month 07
    day 05
    svn rev 76782
    language R
    version.string R version 3.6.1 (2019-07-05)
    nickname Action of the Toes

  6. Jiachen-Ma-code commented on Oct 16, 2019

    @Jiachen-Ma-code

    @ronblum I figured it out. The saving dir contains none English characters, which simply fails the saving process.

  7. ronblum commented on Oct 17, 2019

    @ronblum
    Contributor

    @Rabbita Ah! We have several known issues with Windows file names that contain non-ASCII characters, such as #4469 and #5560. So this falls into this category, unfortunately. We'll be reviewing these as ew continue developing RStudio.

  8. added and removed
    info needed
    on Jan 3, 2020
  9. vitconkue commented on Mar 9, 2020

    @vitconkue

    Still, the same problem, the dir contains some none English characters.
    OS version: Windows 10 R version: 3.6.1 Rstudio version: 1.2.5033Desktop editon

  10. jmcphers commented on May 28, 2020

    @jmcphers
    Member

    The saving dir contains none English characters, which simply fails the saving process.

    Can you give us the exact name of the dir that's causing trouble?

  11. Jiachen-Ma-code commented on Sep 5, 2020

    @Jiachen-Ma-code

    The saving dir contains none English characters, which simply fails the saving process.

    Can you give us the exact name of the dir that's causing trouble?

    Please try this one: "C:\Users\91319\Downloads\非英文路径"

    Annotation 2020-09-05 114128

    Annotation 2020-09-05 114129

  12. kevinushey commented on Sep 8, 2020

    @kevinushey
    Collaborator

    The problem here is likely in the way we invoke the graphics device function:

    // generate code for creating bitmap file device
    boost::format fmt(
    "{ require(grDevices, quietly=TRUE); "
    " %1%(filename=\"%2%\", width=%3%, height=%4%, res = %5% %6%); }");
    std::string deviceCreationCode = boost::str(fmt % bitmapFileType %
    string_utils::utf8ToSystem(targetPath.getAbsolutePath()) %
    width %
    height %
    res %
    extraParams);

    It would likely be safer for us to render the plot to a temporary file (no special characters), and then move the rendered file to the requested destination path.

  13. Jiachen-Ma-code commented on Sep 11, 2020

    @Jiachen-Ma-code

    The problem here is likely in the way we invoke the graphics device function:

    // generate code for creating bitmap file device
    boost::format fmt(
    "{ require(grDevices, quietly=TRUE); "
    " %1%(filename=\"%2%\", width=%3%, height=%4%, res = %5% %6%); }");
    std::string deviceCreationCode = boost::str(fmt % bitmapFileType %
    string_utils::utf8ToSystem(targetPath.getAbsolutePath()) %
    width %
    height %
    res %
    extraParams);

    It would likely be safer for us to render the plot to a temporary file (no special characters), and then move the rendered file to the requested destination path.

    That sounds more robust to me. Does it have an impact on the performance side?

  14. kevinushey commented on Sep 11, 2020

    @kevinushey
    Collaborator

    The main issue here would be that we'd be doing an extra filesystem copy (writing the image to one location, and then moving or copying to the requested location).

  15. added
    stale
    and removed on Feb 12, 2021
  16. removed
    stale
    on Feb 12, 2021
  17. added
    stale
    and removed
    stale
    on Feb 12, 2021
  18. github-actions commented on Feb 17, 2022

    @github-actions

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  19. added
    stale
    on Feb 17, 2022
  20. stale commented on Mar 3, 2022

    @stale

    This issue has been automatically closed due to inactivity.

  21. cz156 commented on Feb 8, 2023

    @cz156

    1675832850(1)

    Then you will solve the problem.

  22. uwemenzel commented on Feb 8, 2023

    @uwemenzel
    Author
    1675832850(1)

    Then you will solve the problem.

    Thanks a lot, cz156 !!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugencodingstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions