Skip to content

Commit

Permalink
fix: removed fs that was causing github issues
Browse files Browse the repository at this point in the history
  • Loading branch information
c1au6i0 committed Jan 2, 2025
1 parent 28f007c commit e97ccf4
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Depends:
R (>= 4.1)
Imports:
cli,
fs,
httr2,
janitor,
pingr,
Expand Down
4 changes: 2 additions & 2 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ save_to_cache <- function(dat, file_name, verbose = FALSE) {
dir.create(cache_dir, recursive = TRUE)
}

file_path <- fs::path(cache_dir, file_name)
file_path <- file.path(cache_dir, file_name)

if (all(file.exists(file_path), verbose)) {
cli::cli_alert_info("Overwriting cache.")
Expand Down Expand Up @@ -65,7 +65,7 @@ read_from_cache <- function(file_name, verbose = FALSE) {

cache_dir <- tools::R_user_dir("extractox", which = "cache")
cache_dir <- normalizePath(cache_dir, mustWork = FALSE)
file_path <- fs::path(cache_dir, file_name)
file_path <- file.path(cache_dir, file_name)

if (file.exists(file_path)) {
out <- readRDS(file_path)
Expand Down
6 changes: 3 additions & 3 deletions R/extr_pprtv.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ extr_pprtv <- function(ids, search_type = "casrn", verbose = TRUE, force = TRUE,
file_name <- "epa_pprtvs.rds" # Filename for caching

# Check if path is present otherwise it download it again
full_path_cache_file <- fs::path(
full_path_cache_file <- file.path(
tools::R_user_dir("extractox",
which = "cache"
),
file_name
)

cache_present <- fs::file_exists(full_path_cache_file)
cache_present <- file.exists(full_path_cache_file)

full_path_cache_file <- normalizePath(full_path_cache_file, mustWork = FALSE)

# fs::dir_exists(Sys.getenv("R_USER_CACHE_DIR"))
# dir.exists(Sys.getenv("R_USER_CACHE_DIR"))

if (any(isTRUE(force), !cache_present, isTRUE(get_all))) {
check_internet(verbose = verbose)
Expand Down
26 changes: 13 additions & 13 deletions renv/activate.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ local({
name <- sprintf("renv_%s%s", version, ext)
url <- paste(baseurl, name, sep = "/")

destfile <- fs::path(tempdir(), name)
destfile <- file.path(tempdir(), name)
status <- tryCatch(
renv_bootstrap_download_impl(url, destfile),
condition = identity
Expand Down Expand Up @@ -326,8 +326,8 @@ local({

name <- sprintf("renv_%s.tar.gz", version)
repos <- renv_bootstrap_repos()
urls <- fs::path(repos, "src/contrib/Archive/renv", name)
destfile <- fs::path(tempdir(), name)
urls <- file.path(repos, "src/contrib/Archive/renv", name)
destfile <- file.path(tempdir(), name)

message("* Downloading renv ", version, " ... ", appendLF = FALSE)

Expand Down Expand Up @@ -361,7 +361,7 @@ local({
# allow directories
if (dir.exists(tarball)) {
name <- sprintf("renv_%s.tar.gz", version)
tarball <- fs::path(tarball, name)
tarball <- file.path(tarball, name)
}

# bail if it doesn't exist
Expand Down Expand Up @@ -409,9 +409,9 @@ local({

message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE)

url <- fs::path("https://api.github.com/repos/rstudio/renv/tarball", version)
url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version)
name <- sprintf("renv_%s.tar.gz", version)
destfile <- fs::path(tempdir(), name)
destfile <- file.path(tempdir(), name)

status <- tryCatch(
renv_bootstrap_download_impl(url, destfile),
Expand All @@ -437,7 +437,7 @@ local({
# invoke using system2 so we can capture and report output
bin <- R.home("bin")
exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R"
r <- fs::path(bin, exe)
r <- file.path(bin, exe)

args <- c(
"--vanilla", "CMD", "INSTALL", "--no-multiarch",
Expand Down Expand Up @@ -662,7 +662,7 @@ local({
type <- renv_bootstrap_project_type(project)
if (identical(type, "package")) {
userdir <- renv_bootstrap_user_dir()
return(fs::path(userdir, "library"))
return(file.path(userdir, "library"))
}

}
Expand Down Expand Up @@ -756,7 +756,7 @@ local({
renv_bootstrap_profile_prefix <- function() {
profile <- renv_bootstrap_profile_get()
if (!is.null(profile))
return(fs::path("profiles", profile, "renv"))
return(file.path("profiles", profile, "renv"))
}

renv_bootstrap_profile_get <- function() {
Expand Down Expand Up @@ -800,7 +800,7 @@ local({

renv_bootstrap_project_type <- function(path) {

descpath <- fs::path(path, "DESCRIPTION")
descpath <- file.path(path, "DESCRIPTION")
if (!file.exists(descpath))
return("unknown")

Expand Down Expand Up @@ -846,12 +846,12 @@ local({
for (envvar in envvars) {
root <- Sys.getenv(envvar, unset = NA)
if (!is.na(root))
return(fs::path(root, "R/renv"))
return(file.path(root, "R/renv"))
}

# use platform-specific default fallbacks
if (Sys.info()[["sysname"]] == "Windows")
fs::path(Sys.getenv("LOCALAPPDATA"), "R/cache/R/renv")
file.path(Sys.getenv("LOCALAPPDATA"), "R/cache/R/renv")
else if (Sys.info()[["sysname"]] == "Darwin")
"~/Library/Caches/org.R-project.R/R/renv"
else
Expand Down Expand Up @@ -996,7 +996,7 @@ local({
prefix <- renv_bootstrap_platform_prefix()

# construct full libpath
libpath <- fs::path(root, prefix)
libpath <- file.path(root, prefix)

# attempt to load
if (renv_bootstrap_load(project, libpath, version))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-chace.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_that("Save to cache works", {
"Saving"
)

exp_path <- normalizePath(fs::path(
exp_path <- normalizePath(file.path(
Sys.getenv("R_USER_CACHE_DIR"), "R",
"extractox", "song.txt"
))
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test_pprtv.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ test_that("extr_pprtv casrn hit and not hit, verbose, force = TRUE", {
"Extracting EPA PPRTVs."
)

tmp_out <- fs::path(temp_dir, "R", "extractox")
cache_exist <- fs::file_exists(fs::path(tmp_out, "epa_pprtvs.rds"))
tmp_out <- file.path(temp_dir, "R", "extractox")
cache_exist <- file.exists(file.path(tmp_out, "epa_pprtvs.rds"))

expect_true(cache_exist)
expect_equal(nrow(out), length(ids_search))
Expand Down Expand Up @@ -86,8 +86,8 @@ test_that("extr_pprtv na,es hit and not hit, verbose, force = TRUE", {
"Extracting EPA PPRTVs."
)

tmp_out <- fs::path(temp_dir, "R", "extractox")
cache_exist <- fs::file_exists(fs::path(tmp_out, "epa_pprtvs.rds"))
tmp_out <- file.path(temp_dir, "R", "extractox")
cache_exist <- file.exists(file.path(tmp_out, "epa_pprtvs.rds"))

expect_equal(nrow(out), 11)
})

0 comments on commit e97ccf4

Please sign in to comment.