Skip to content

Commit

Permalink
fix more lints
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-baumann committed Sep 14, 2024
1 parent 308960b commit b55a097
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion R/make_nixpkgs_url.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ make_nixpkgs_url <- function(r_ver) {
latest_commit <- get_latest(r_ver)

list(
"url" = paste0("https://github.com/", github_repo, "archive/", latest_commit, ".tar.gz"),
"url" = paste0(
"https://github.com/", github_repo, "archive/", latest_commit, ".tar.gz"
),
"latest_commit" = latest_commit,
"r_ver" = r_ver
)
Expand Down
9 changes: 7 additions & 2 deletions R/nix_hash.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,21 @@ nix_sri_hash <- function(path) {

# not needed for Nix R sessions, workaround on Debian and Debian-based
# systems with nix installed
# nolint start: object_name_linter
LD_LIBRARY_PATH_default <- Sys.getenv("LD_LIBRARY_PATH")
needs_ld_fix <- isFALSE(nzchar(Sys.getenv("NIX_STORE"))) &&
nzchar(LD_LIBRARY_PATH_default)
# nolint end

if (isTRUE(needs_ld_fix)) {
# On Debian and Debian-based systems, like Ubuntu 22.04, we found that a
# preset `LD_LIBRARY_PATH` environment variable in the system's R session
# leads to errors like
# nix-hash: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by nix-hash)
# nix-hash: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /nix/store/4z754a0vzl98asv0pa95i5d9szw5jqbs-lowdown-1.0.2-lib/lib/liblowdown.so.3)
# nix-hash: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38'
# not found (required by nix-hash)
# nix-hash: /usr/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38'
# not found (required by # nolint next: line_length_linter
# /nix/store/4z754a0vzl98asv0pa95i5d9szw5jqbs-lowdown-1.0.2-lib/lib/liblowdown.so.3)
# etc...
# for both `nix-hash`; it occurs via
# `sys::exec_internal`, `base::system()` or `base::system2()` from R.
Expand Down
6 changes: 5 additions & 1 deletion R/with_nix.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ with_nix <- function(expr,
project_path = ".",
message_type = c("simple", "quiet", "verbose")) {
nix_file <- file.path(project_path, "default.nix")
# nolint start: line_length_linter
stopifnot(
"`project_path` must be character of length 1." =
is.character(project_path) && length(project_path) == 1L,
Expand All @@ -143,6 +144,7 @@ with_nix <- function(expr,
"`expr` needs to be a call or function for `program = R`, and character of length 1 for `program = shell`" =
is.function(expr) || is.call(expr) || (is.character(expr) && length(expr) == 1L)
)
# nolint end

program <- match.arg(program, choices = c("R", "shell"))
message_type <- match.arg(message_type,
Expand Down Expand Up @@ -170,11 +172,12 @@ with_nix <- function(expr,
current_libpaths <- .libPaths()
# don't do this in covr test environment, because this sets R_LIBS_USER
# to multiple paths
R_LIBS_USER <- Sys.getenv("R_LIBS_USER")
R_LIBS_USER <- Sys.getenv("R_LIBS_USER") # nolint: object_name_linter
if (isFALSE(nzchar(Sys.getenv("R_COVR")))) {
remove_r_libs_user()
}
} else {
# lolint start: object_name_linter
LD_LIBRARY_PATH_default <- Sys.getenv("LD_LIBRARY_PATH")
if (nzchar(LD_LIBRARY_PATH_default)) {
# On some systems, like Ubuntu 22.04, we found that a preset
Expand All @@ -195,6 +198,7 @@ with_nix <- function(expr,
)
cat("\n", "Setting `LD_LIBRARY_PATH` to `''` during `nix_build()`")
}
# nolint end
}

has_nix_shell <- nix_shell_available() # TRUE if yes, FALSE if no
Expand Down

0 comments on commit b55a097

Please sign in to comment.