Skip to content

Posit Assistant install fails on Windows with R < 4.2 when the user data path has non-ASCII characters #19625

Closed

Description

@gtritchie

System details

RStudio Edition : Desktop
RStudio Version : 2026.12.0-daily+131
OS Version      : Windows 11
R Version       : R < 4.2 (tested with R 4.1.3); R 4.6.1 works

Steps to reproduce the problem

  1. Configure RStudio to use R 4.1 or earlier.

  2. Make RStudio's user data directory a non-ASCII path. In practice that happens when the Windows profile name is non-ASCII (e.g. C:\Users\José, which puts the data directory under C:\Users\José\AppData\Local\RStudio). To simulate it, launch RStudio from PowerShell with RSTUDIO_DATA_HOME pointing to a folder such as C:\temp\data-é:

    $env:RSTUDIO_DATA_HOME = 'C:\temp\data-é'; & 'C:\Program Files\RStudio\rstudio.exe'
    
  3. Install Posit Assistant from the chat pane.

Describe the problem in detail

The install fails with:

Update failed: Installation failed: Downloaded package declares version " for protocol", but version '1.12.0' for protocol '11.0' was requested

The hostname here is ASCII, so this is independent of #19624.

installPackage() in src/cpp/session/modules/SessionChat.cpp creates a staging directory under <data dir>\pai\versions, then extracts the package with R's unzip(exdir = stagingDir.getAbsolutePath()). The path is UTF-8, but RFunction passes strings to R as CE_NATIVE (r::sexp::create(), src/cpp/r/RSexp.cpp). With R < 4.2 the native encoding is the system code page (e.g. 1252), so R reads é (C3 A9) as é and unzip() creates and extracts into a parallel tree:

  • staging directory created by rsession: data-é\pai\versions\.tmp-the-pc-20816-… (left empty)
  • directory R extracted into: data-é\pai\versions\.tmp-the-pc-20816-… (C3 83 C2 A9)

verifyDeclaredIdentity() reads the empty staging directory, so the declared version and protocol come back blank. The extracted tree (~23 MB) is never cleaned up, and every retry adds another.

With R 4.2 and later the native encoding is UTF-8, so the same setup installs normally (tested with R 4.6.1).

The Windows R < 4.2 failure in #19624 ends in the same unzip() handoff, which is why both produce the same error.

Describe the behavior you expected

Posit Assistant installs when the user data directory has non-ASCII characters. The exdir path should reach R as a correctly encoded string, for example marked as UTF-8, so R and rsession agree on the directory.

Activity

  1. gtritchie commented on Nov 13, 2026

    @gtritchie
    MemberAuthor

    The RSTUDIO_DATA_HOME repro exercises only exdir. Two more paths reach R through the same CE_NATIVE conversion in src/cpp/session/modules/SessionChat.cpp, and neither is under the data directory:

    • destfile in downloadPackage() (passed to .rs.chat.downloadPackage)
    • zipfile in installPackage() (passed to unzip())

    Both point at the download temp file from module_context::tempFile(), which lives in R's session temp directory. With a real non-ASCII profile such as C:\Users\José, that directory is under the profile too (AppData\Local\Temp). The download would then probably fail before extraction, with "Download failed: ..." or "Downloaded file is empty or missing" rather than the "declares version" error. This is inferred from the code, not tested; it doesn't apply if Windows or R hands back an ASCII 8.3 short path for the temp directory.

    The fix should pass all three path parameters with addUtf8Param, not just exdir. Confirming the download side needs a test on a Windows account with a non-ASCII username.

  2. self-assigned this
    on Nov 13, 2026
  3. added theissue type on Nov 13, 2026
  4. gtritchie commented on Nov 13, 2026

    @gtritchie
    MemberAuthor

    The error message is misleading because installPackage() never checks where unzip() put the files. In this bug, unzip() does not fail: it extracts the whole package into the misread directory and returns normally. installPackage() then calls verifyDeclaredIdentity() on the empty staging directory, and the user sees "declares version '' for protocol ''" instead of anything about extraction.

    (When R can't write into exdir, unzip() does raise an R error, which installPackage() already reports. Tested with R 4.6.2 and an unwritable exdir.)

    Alongside the encoding fix, installPackage() could check after unzip() that the staging directory is not empty, or that the paths unzip() returns are under it, and fail with an error naming the staging directory. A future mismatch like this one would then report where extraction went wrong instead of a blank version.

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions