Skip to content

ensure UTF8 encoding in completion routines - #372

Merged
jjallaire merged 2 commits into
masterfrom
bugfix/completion-encoding
Mar 31, 2015
Merged

jjallaire merged 2 commits into
masterfrom
bugfix/completion-encoding

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

This PR fixes a problem in autocompletion of items with non-ASCII characters -- we ensure that all character vectors are re-marked with UTF-8 encoding.

Without this PR, entries like CAFÉ were interpretted as CAFÉ/, and so autocompletion couldn't properly resolve the path.

jjallaire added a commit that referenced this pull request Mar 31, 2015
ensure UTF8 encoding in completion routines
@jjallaire
jjallaire merged commit 09602de into master Mar 31, 2015
@jjallaire
jjallaire deleted the bugfix/completion-encoding branch March 31, 2015 18:41
kevinushey added a commit that referenced this pull request Apr 30, 2026
Address roborev #372:

- .rs.installPackagesWhichDeps now returns list(direct, transitive). The
  install.packages hook expands direct deps non-recursively (which may
  include Suggests when dependencies = TRUE) and recurses only through
  the transitive (strong) set. Mirrors install.packages's
  getDependencies() so the candidate scan isn't over-expanded by
  Suggests-of-Suggests chains install.packages won't follow.

- Create one sentinel per 'lib' entry. The per-path libStart recycles
  position-wise against paths built from outer(lib, candidates, ...),
  so cross-filesystem clock skew between library entries can't mask
  real installs in non-primary libraries.

- Filter NA_character_ out of the user's 'dependencies' argument
  before passing to tools::package_dependencies(which = ...).

Tests updated for the new list shape, plus a case for NA filtering.
kevinushey added a commit that referenced this pull request Apr 30, 2026
* scope install.packages hook scan to dependency closure

The post-install file.info diff that the install.packages hook uses to
identify which packages changed now scans only the requested packages
and their dependency closure (as computed from the user's 'dependencies'
argument), rather than the entire library. Avoids O(library) filesystem
work per install on large libraries or slow filesystems.

Addresses rstudio/rstudio-pro#10771.

* tighten console package-call detection regex

Replaces the onConsolePrompt substring match against 'install', 'update',
'remove', etc. with a compiled regex that requires an opening '(' after
the identifier. Stops spurious Packages pane refreshes from benign input
like 'updates <- c(1, 2)' or 'installed.packages()', while still catching
base R, devtools/remotes, pak, pacman, and renv entry points. Keywords
are listed one per line so it's easy to extend.

Addresses rstudio/rstudio-pro#10771.

* scan only the first library path in install.packages hook

install.packages writes to lib[[1L]] in the common case; restrict the
before/after file.info scan to that path rather than every entry of lib.

* drop incorrect multi-lib dependencies override

install.packages only coerces 'dependencies' to FALSE in the multi-lib
case when the user hadn't supplied a value (i.e. it was NA). An explicit
TRUE/FALSE/character vector is respected as-is. Since the before/after
scan is already restricted to lib[[1L]], over-approximating the candidate
set in the multi-lib case is harmless — paths for packages that landed
in other libraries simply don't appear in either snapshot.

* drop before-scan in install.packages hook; use fs-pinned timestamp

Replaces the before/after file.info diff with a single post-install scan
whose reference time is read from a freshly-created sentinel file in the
target library. Halves the filesystem work performed by the hook and
avoids clock-skew concerns between R's Sys.time() and the library
filesystem (relevant for NFS / CIFS).

* drop redundant ctime check in install.packages hook

* add allow-package-source-recording session option

Introduces an admin-controlled session option (default true) that
suppresses post-install tagging of DESCRIPTION files with RemoteType /
RemoteRepos fields. When disabled, the install.packages hook skips the
available.packages() fetch, dep-closure computation, sentinel write,
post-install scan, and recordPackageSource step entirely.

Useful for deployments where admins want to avoid mutating DESCRIPTION
files in installed package directories, or where the Packages pane's
detailed Source column is not needed.

* query available.packages() with the same 'repos' as install.packages

Previously we called utils::available.packages() with no arguments, so it
read getOption("repos") regardless of what the user passed to
install.packages(). If those disagreed (e.g. install.packages(..., repos =
internal_url)), the db used by recordPackageSource could annotate packages
with the wrong RemoteRepos URL. Threading the hook's 'repos' formal through
keeps available.packages() and install.packages() consistent.

* harden install.packages hook and add test coverage

- guard available.packages() lookup with tryCatch; on failure, log INFO and
  skip post-install source recording rather than failing the user's install
- check file.create(sentinel) return value; fall back to Sys.time() with a
  warning when the library directory isn't writable
- log when requested packages aren't present in available.packages() so a
  'repos' mismatch is debuggable
- scan every entry of 'lib' (install.packages recycles it against 'pkgs')
  instead of only lib[[1L]]
- split the regex comment in SessionPackages.cpp to separately explain the
  '\(' and '[._]' gates
- extract whichDeps mapping into .rs.installPackagesWhichDeps for testability
- expose isPackageManagementCall via SessionPackages.hpp; refactor
  onConsolePrompt to use it; add SessionPackagesTests.cpp with 9 gtest cases
- add testthat tests for .rs.installPackagesWhichDeps, NA-mtime in
  installedPackagesFileInfo(paths=), no-op reinstall tagging, and the
  recordPackageSource(db=) skip-network contract

* match install.packages dep semantics; per-library sentinels

Address roborev #372:

- .rs.installPackagesWhichDeps now returns list(direct, transitive). The
  install.packages hook expands direct deps non-recursively (which may
  include Suggests when dependencies = TRUE) and recurses only through
  the transitive (strong) set. Mirrors install.packages's
  getDependencies() so the candidate scan isn't over-expanded by
  Suggests-of-Suggests chains install.packages won't follow.

- Create one sentinel per 'lib' entry. The per-path libStart recycles
  position-wise against paths built from outer(lib, candidates, ...),
  so cross-filesystem clock skew between library entries can't mask
  real installs in non-primary libraries.

- Filter NA_character_ out of the user's 'dependencies' argument
  before passing to tools::package_dependencies(which = ...).

Tests updated for the new list shape, plus a case for NA filtering.

* read DESCRIPTION directly in recordPackageSource skip check

The skip-if-already-tagged guard read via packageDescription(), which
prefers Meta/package.rds over DESCRIPTION. The function then appends
Remote* lines to DESCRIPTION. If the two are out of sync (e.g. after
a manual rebuild that regenerated package.rds from a tagged
DESCRIPTION), the guard would miss and we'd append a duplicate set of
Remote* lines. Reading via read.dcf(descPath) makes the guard
consistent with the write target.

Also bump degraded-mode logs from logInfoMessage to logWarningMessage:
available.packages() failures and packages absent from db both mean
silent loss of source tagging, which is worth surfacing at the
default log level.

Tests:
- new no-op assertion for recordPackageSource(character(), db = ...)
- new integration test for the transitive-dep tagging path
  (install.packages('B') with B Imports A, both DESCRIPTIONs tagged)
- generalize the local-source-repo helper to take a list of package
  specs so the dep test can build A and B in one repo
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.

3 participants