Skip to content

fix the Posit Assistant install on Windows with R < 4.2 and non-ASCII paths - #19628

Merged
gtritchie merged 10 commits into
mainfrom
bugfix/19625-non-ascii-data-path
Nov 14, 2026
Merged

gtritchie merged 10 commits into
mainfrom
bugfix/19625-non-ascii-data-path

Conversation

@gtritchie

@gtritchie gtritchie commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #19625.

On Windows with R < 4.2, installing Posit Assistant failed when the user data or temp path had non-ASCII characters. RFunction::addParam() marks strings as native encoding, which there is the system code page, so R read a UTF-8 é as é and unzip() extracted into a sibling directory. The install then reported Downloaded package declares version '' for protocol '' and left the extracted package behind.

  • The download and extraction paths (destfile, zipfile, exdir) are passed to R with addUtf8Param().
  • Extraction goes through a new .rs.chat.extractPackage helper. unzip() reports a zip it can't open, or an entry it can't write, as a warning and returns normally, so any warning or error fails the extraction and becomes the reason shown. .rs.chat.downloadPackage and the new helper share their condition handling in .rs.chat.failureReason(). For a download, a warning only fails it alongside an error or a non-zero status, as before.
  • verifyDeclaredIdentity() reports a missing package.json, with the requested version and protocol, instead of a blank declared version.

Characters outside the system code page (e.g. Chinese on an English-language system) still can't be used with R < 4.2. The install now fails with R's reason. The NEWS entry says so.

The same addParam(getAbsolutePath()) pattern in the Files pane upload is filed separately as #19627.

Testing

  • Manual, dev build, R 4.1.3, with RSTUDIO_DATA_HOME and TEMP both pointing to directories ending in -é: Posit Assistant installed and selected slot 1.12.0. No é directory was created and no staging directory was left behind. With the released build and only RSTUDIO_DATA_HOME set, the install failed as described in Posit Assistant install fails on Windows with R < 4.2 when the user data path has non-ASCII characters #19625.
  • The R 4.1.3 unzip() behavior itself, outside RStudio: native-marked paths fail, UTF-8-marked paths extract correctly. R 4.6.1 handles both.
  • rsession tests: ChatInstallation* pass, including a new test for an empty staging directory.
  • R tests: test-chat.R passes on R 4.6.1, including new chat.extractPackage tests that run the real unzip() on a valid zip and a corrupt zip. The new tests also pass when run standalone on R 4.1.3.
  • Not tested on a Windows account whose user name is non-ASCII; RSTUDIO_DATA_HOME and TEMP were used to simulate it.

R < 4.2 on Windows read the native-marked UTF-8 paths in the system code
page, so a non-ASCII data or temp path made unzip() extract into a
different directory than the staging directory rsession checks.

Addresses #19625.
unzip() returns normally when R extracts somewhere other than the
staging directory, so the empty directory surfaced as a package that
declares version '' for protocol ''. Fail instead with an error naming
the directory.

Addresses #19625.
unzip() reports a zip it cannot open, or an entry it cannot write, as a
warning and returns normally, so a partial extraction reached the
install checks as if it had succeeded. Extract through
.rs.chat.extractPackage, which returns the warnings and errors as the
failure reason the way .rs.chat.downloadPackage does, and drop the
empty-staging check this makes redundant.

Addresses #19625.
Replace verifyExtracted() with a check in verifyDeclaredIdentity(): an
extraction into the wrong directory left an empty staging directory,
reported as "declares version '' for protocol ''". It now reports
"Downloaded package has no package.json in <dir>".

Addresses #19625.
@gtritchie gtritchie added this to the 2026.12 (Parrot Balsam) milestone Nov 13, 2026
@gtritchie
gtritchie requested a review from kevinushey November 13, 2026 21:38
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
5612 0 256 3
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1408 0 46 0
✅ desktop-macos 1403 0 51 1
✅ desktop-windows 1401 0 57 2
✅ server-linux 1348 0 54 0
✅ setup 48 0 32 0

View report online


All platforms - commit caf922cb50caa75c2dd0b40857dac6ce8a0c90f6 - Run #2281

@gtritchie

Copy link
Copy Markdown
Member Author

Code review findings

Actionable items from an automated code review of 3e14db6.

Important

  1. src/cpp/session/modules/chat/ChatInstallation.cpp:117: the new missing-package.json error names the staging directory, but installPackage() calls discardStaging(error) right after the check (SessionChat.cpp:4430-4432). The path the user sees no longer exists. The message also drops the requested version, which the old declares version '' message included. The comment's "points at where extraction went wrong" names where extraction should have gone, not where it went wrong. Fix: say "Downloaded package has no package.json (expected version X)" and drop the path, or keep the path and correct the comment. allocateSlot() names the staging dir the same way (ChatSlots.cpp:315).

  2. src/cpp/tests/testthat/test-chat.R:210: no test checks that chat.extractPackage leaves warnings unmuffled, as its doc comment promises. The only corrupt-zip test wraps the call in suppressWarnings; chat.downloadPackage has a "leaves download warnings visible" test for this. The C++ branch in installPackage() that turns a non-empty reason into a failure and discards staging is also untested. Dropping that !reason.empty() check would pass every test and let a partial extraction through, which is the Posit Assistant install fails on Windows with R < 4.2 when the user data path has non-ASCII characters #19625 failure class. Fix: add an expect_warning test for extract. Cover the C++ branch if installPackage() can be made testable.

Suggestions

  1. src/cpp/session/modules/SessionChat.R:1260: chat.extractPackage repeats chat.downloadPackage's condition handling: the withCallingHandlers + tryCatch collection, the warn=2 dedup filter (lines 1244 and 1276), and the paste(collapse = "; "). The C++ callers also repeat the reason → io_error conversion. Fix: factor out a shared helper, e.g. .rs.chat.failureReason(expr).

  2. src/cpp/session/modules/SessionChat.cpp:4415: the encoding bug is fixed at three call sites. 12 other RFunction::addParam(...getAbsolutePath()) calls still mark UTF-8 paths as native:

    Fix: add a FilePath-aware addParam/sexp::create overload that marks UTF-8, so call sites can't pick the native form by accident. Fixing each site separately is also reasonable, since addUtf8Param and utf8ToSystem are both established.

  3. src/cpp/session/modules/chat/ChatInstallationTests.cpp:265: RejectsAnEmptyDirectoryByName reaches the same !isRegularFile() early return as the strengthened RejectsAPackageWithoutPackageJson, and makes the same path assertion. Fix: drop it, or fold its Posit Assistant install fails on Windows with R < 4.2 when the user data path has non-ASCII characters #19625 comment into the existing test.

installPackage() removes the staging directory as soon as
verifyDeclaredIdentity() fails, so the missing package.json error named
a path that no longer existed. It now says which version and protocol
were requested, as the mismatch error does. Drop the test that
duplicated RejectsAPackageWithoutPackageJson.

Addresses #19625.
.rs.chat.failureReason() collects the error and warnings that
chat.downloadPackage and chat.extractPackage each gathered by hand.
warningsFail keeps their difference: a warning alone fails an
extraction, but not a download that returned status 0, such as one
using the deprecated wininet method. On the C++ side,
callReportingFailure() turns the returned reason into an error for
both callers.

Addresses #19625.

@kevinushey kevinushey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me; nothing blocking. I ran the new chat.downloadPackage / chat.extractPackage tests standalone against the helpers at caf922c on R 4.6.1 and they pass. Treating any unzip() warning as a failure also looks safe: everything it warns about (corrupt archive, CRC or write error, ../ path components, extraction through a symlink) is a bad extraction.

Two notes, neither needing action before merge:

  • No automated test covers the three addUtf8Param call sites; reverting them leaves every test passing. Reproducing the bug needs a non-UTF-8 Windows session (R <= 4.1), so the manual run in the description is the coverage here.
  • The description's Testing section still lists "a new test for an empty staging directory", which a later commit dropped. Worth trimming before the squash.

// on Windows, native is the system code page, so a non-ASCII path (a user
// name such as José) would name a different directory in R than here.
r::exec::RFunction extract(".rs.chat.extractPackage");
extract.addUtf8Param("zipfile", packagePath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking, and I don't think it needs a change. On POSIX this trades one edge case for another: a FilePath there holds whatever bytes the filesystem uses, and R honours the UTF-8 mark by translating to the session's native encoding. In a non-UTF-8 locale with a non-ASCII data or temp directory, the native-marked path used to work and the UTF-8-marked one doesn't (R 4.6.1 on macOS, unzip() into a directory under café/):

LC_ALL=C                 unable to translate '.../caf<U+00E9>/out' to native encoding
LC_ALL=en_US.ISO8859-1   'exdir' does not exist

The session already forces a UTF-8 charset on Linux and warns when it can't, utf8ToSystem() assumes the same, and the other addUtf8Param(path) call sites behave this way, so this is consistent with the rest of the codebase. Mentioning it because the comment reads as if these paths are UTF-8 on every platform.

@gtritchie
gtritchie merged commit d9e89ee into main Nov 14, 2026
47 checks passed
@gtritchie
gtritchie deleted the bugfix/19625-non-ascii-data-path branch November 14, 2026 01:37
@kevinushey kevinushey mentioned this pull request Nov 15, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants