REditorSupport / REditorSupport/languageserver

`fs::path_has_parent` does not work if the locale is not set correctly on Windows

Open
#279 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
675
Forks
118
Avg merge
1d 37m
Merged PRs (30d)
11

Description

I discovered it when investigating #277.

r$> Sys.setlocale(locale = "english")
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;L"
r$> fs::path_has_parent(enc2utf8("c:/Users/中文"), "c:/ProgramData/")
Error in if (xi > xj) 1L else -1L : missing value where TRUE/FALSE needed

r$> Sys.setlocale(locale = "chinese")
[1] "LC_COLLATE=Chinese (Simplified)_China.936;LC_CTYPE=Chinese (Simplified)_China.936;LC_MONETARY=Chinese (Simplified)"
r$> fs::path_has_parent(enc2utf8("c:/Users/中文"), "c:/ProgramData/")
[1] FALSE

Windows paths are in Unicode. It is not reasonable to assume that the characters in a path are compatible with the chosen locale.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two calls to fs::path_has_parent shown in the report on Windows, using the English and Chinese locales. Trace the entry point and its handling of the Unicode path; done means the English-locale case no longer errors and returns the expected parent relationship.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.