Skip to content

Commit 91d6d11

Browse files
nbafrankclaude
andcommitted
#17: preserve user's site library when prepending project lib
B-Nilson clarified the original report: `.libPaths(lib)` with a single argument causes R to drop the user's site library (`~/R/x86_64-pc-linux-gnu-library/4.x` on Linux, similar elsewhere) in favour of `[lib, system_lib]` only. Packages the user installed into their site library become invisible inside the project. Switch to `.libPaths(unique(c(lib, .libPaths())))`: prepend the project library (so it still wins resolution) while preserving whatever paths R had already set up. The dedupe collapses the common case where lib was already on the path. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 6a9d36d commit 91d6d11

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

crates/uvr/src/commands/init.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ local({
149149
}
150150
}
151151
if (dir.exists(lib)) {
152-
.libPaths(lib)
152+
# #17: `.libPaths(lib)` with a single new path causes R to drop the
153+
# user's site library (e.g. ~/R/x86_64-pc-linux-gnu-library/4.4) —
154+
# only the new path and the system library survive. Prepending via
155+
# `unique(c(lib, .libPaths()))` keeps the project lib first (so it
156+
# wins resolution) while preserving anything the user already had.
157+
.libPaths(unique(c(lib, .libPaths())))
153158
n_locked <- count_locked(lock)
154159
installed <- list.dirs(lib, recursive = FALSE, full.names = FALSE)
155160
n_installed <- length(setdiff(installed, "uvr"))

0 commit comments

Comments
 (0)