This is an automated email from the ASF dual-hosted git repository.
thisisnic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 7b14b2b271 GH-36638: [R] Error with
create_package_with_all_dependencies() on Windows (#37226)
7b14b2b271 is described below
commit 7b14b2b2712bc483cd7d14bbc6c38e26d27074ac
Author: Nic Crane <[email protected]>
AuthorDate: Mon Sep 25 09:05:40 2023 +0100
GH-36638: [R] Error with create_package_with_all_dependencies() on Windows
(#37226)
### Rationale for this change
Fix path to directory which stops `create_package_with_all_dependencies()`
working on Windows
### What changes are included in this PR?
Character replacement in the script to ensure that on Windows,
wsl-comaptible path is used and paths are normalised.
### Are these changes tested?
I tested it locally myself and it works - there are no tests for this
function.
### Are there any user-facing changes?
Nope
* Closes: #36638
Authored-by: Nic Crane <[email protected]>
Signed-off-by: Nic Crane <[email protected]>
---
r/R/install-arrow.R | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R
index 7017d4f39b..715478f6d0 100644
--- a/r/R/install-arrow.R
+++ b/r/R/install-arrow.R
@@ -215,19 +215,25 @@ create_package_with_all_dependencies <-
function(dest_file = NULL, source_file =
untar_dir <- tempfile()
on.exit(unlink(untar_dir, recursive = TRUE), add = TRUE)
utils::untar(source_file, exdir = untar_dir)
- tools_dir <- file.path(untar_dir, "arrow/tools")
+ tools_dir <- file.path(normalizePath(untar_dir, winslash = "/"),
"arrow/tools")
download_dependencies_sh <- file.path(tools_dir,
"download_dependencies_R.sh")
# If you change this path, also need to edit nixlibs.R
download_dir <- file.path(tools_dir, "thirdparty_dependencies")
dir.create(download_dir)
download_script <- tempfile(fileext = ".R")
+
+ if (isTRUE(Sys.info()["sysname"] == "Windows")) {
+ download_dependencies_sh <- wslify_path(download_dependencies_sh)
+ }
+
parse_versions_success <- system2(
"bash", c(download_dependencies_sh, download_dir),
stdout = download_script,
stderr = FALSE
) == 0
+
if (!parse_versions_success) {
- stop("Failed to parse versions.txt")
+ stop(paste("Failed to parse versions.txt; view ", download_script, "for
more information", collapse = ""))
}
# `source` the download_script to use R to download all the dependency
bundles
source(download_script)
@@ -250,3 +256,14 @@ create_package_with_all_dependencies <- function(dest_file
= NULL, source_file =
}
invisible(dest_file)
}
+
+# Convert a Windows path to a WSL path
+# e.g. wslify_path("C:/Users/user/AppData/") returns
"/mnt/c/Users/user/AppData"
+wslify_path <- function(path) {
+ m <- regexpr("[A-Z]:/", path)
+ drive_expr <- regmatches(path, m)
+ drive_letter <- strsplit(drive_expr, ":/")[[1]]
+ wslified_drive <- paste0("/mnt/", tolower(drive_letter))
+ end_path <- strsplit(path, drive_expr)[[1]][-1]
+ file.path(wslified_drive, end_path)
+}