Skip to content

Uploading a zip in the Files pane extracts to the wrong folder on Windows with R < 4.2 when the path has non-ASCII characters #19627

Closed

Description

@gtritchie

System details

RStudio Edition : Desktop and Server
RStudio Version : 2026.12.0-daily
OS Version      : Windows
R Version       : R < 4.2

Steps to reproduce the problem

  1. Configure RStudio to use R 4.1 or earlier.
  2. In the Files pane, go to a folder whose path has non-ASCII characters, e.g. C:\temp\test-é (or any folder under a profile such as C:\Users\José).
  3. Upload a .zip file with Upload.

Describe the problem in detail

Uploading a zip in the Files pane expands it with R's unzip() (src/cpp/session/modules/SessionFiles.cpp, around line 927). Both paths are passed with addParam(path.getAbsolutePath()). That marks the UTF-8 path as native encoding (r::sexp::create() in src/cpp/r/RSexp.cpp). Under R < 4.2 on Windows, native is the system code page, so R reads é (C3 A9) as é. unzip() then extracts into a sibling directory such as test-é, or fails to find the uploaded zip if the session temp directory is under a non-ASCII profile.

This is the same handoff as #19625, where it broke the Posit Assistant install. It is inferred from the code and has not been reproduced in the Files pane. The unzip() behavior itself was confirmed on R 4.1.3 for #19625: a native-marked UTF-8 exdir extracts into the é directory, and a UTF-8-marked one extracts correctly.

Other RFunction callers pass getAbsolutePath() through addParam() too. A general fix is an RFunction::addParam overload for FilePath that always marks UTF-8 (r::sexp::createUtf8(const FilePath&) already exists), so callers can't pick the wrong encoding.

Describe the behavior you expected

The zip is expanded into the folder it was uploaded to.

Activity

  1. gtritchie commented on Nov 13, 2026

    @gtritchie
    MemberAuthor

    The Files pane isn't the only place this happens. These RFunction::addParam() calls also pass FilePath::getAbsolutePath() (UTF-8) to R marked as native encoding, so with R < 4.2 on Windows a non-ASCII path names a different file in R:

    • src/cpp/session/modules/SessionFiles.cpp:928, :929 (zip upload, described above)
    • src/cpp/r/session/graphics/RGraphicsPlotManager.cpp:362, :371, :381
    • src/cpp/r/session/graphics/RGraphicsPlotManipulator.cpp:62, :70
    • src/cpp/session/modules/SessionDiagnostics.cpp:1008
    • src/cpp/session/modules/SessionRenv.cpp:144
    • src/cpp/session/modules/SessionTutorial.cpp:107, :401, :411

    Other callers already handle this, either with addUtf8Param() or by converting with string_utils::utf8ToSystem() first. Rather than fixing each site, an addParam overload for FilePath that always marks UTF-8 (using the existing r::sexp::createUtf8(const FilePath&)) would stop new call sites from repeating the mistake. Like #19625, characters outside the system code page still won't work with R < 4.2.

    Found in review of #19628, which fixes the Posit Assistant install paths only. None of these sites has been reproduced individually.

  2. added theissue type on Nov 13, 2026
  3. self-assigned this
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions