Skip to content

Commit c809ef7

Browse files
e-kotovgoogle-labs-jules[bot]Copilot
authored
Fix cran (#99)
* Add devcontainer configuration for R project - Use `mcr.microsoft.com/devcontainers/r:latest` as base image. - Exclude `rJava` from dependency installation to keep container Java-free. - Install Posit Air CLI and VS Code extension. - Install Quarto extension. * Add devcontainer configuration for R project - Use `mcr.microsoft.com/devcontainers/r:latest` as base image. - Exclude `rJava` from dependency installation to keep container Java-free. - Install Posit Air CLI and VS Code extension. - Install Quarto extension. - Update scripts to address PR review feedback (robust dependency handling, verification). * Add devcontainer configuration for R project - Use `mcr.microsoft.com/devcontainers/r:latest` as base image. - Exclude `rJava` from dependency installation to keep container Java-free. - Install Posit Air CLI and VS Code extension. - Install Quarto extension. - Update scripts to address PR review feedback (pinned version, security, robustness). * fixes for cran following winbuilder tests * Update R/java_install.R Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b4a223a commit c809ef7

File tree

13 files changed

+131
-39
lines changed

13 files changed

+131
-39
lines changed

.Rbuildignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@
3434
^\.jupyter$
3535
^[.]?air[.]toml$
3636
^\.vscode$
37-
^\.devcontainer$
37+
^\.sync$
3838
^\.claude$
39+
^\.devcontainer$

.devcontainer/devcontainer.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "rJavaEnv Dev Container",
3+
"image": "mcr.microsoft.com/devcontainers/r:latest",
4+
"features": {
5+
"ghcr.io/devcontainers/features/common-utils:2": {}
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"quarto.quarto",
11+
"Posit.air-vscode",
12+
"REditorSupport.r"
13+
]
14+
}
15+
},
16+
"postCreateCommand": "bash .devcontainer/setup.sh",
17+
"remoteEnv": {
18+
"PATH": "${containerEnv:PATH}:/home/vscode/.local/bin"
19+
}
20+
}

.devcontainer/setup.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env Rscript
2+
3+
# Ensure remotes is installed
4+
if (!requireNamespace("remotes", quietly = TRUE)) {
5+
install.packages("remotes")
6+
}
7+
8+
# Get dependencies from DESCRIPTION in the current directory
9+
deps <- remotes::dev_package_deps(dependencies = TRUE)
10+
11+
# Filter out rJava to ensure no Java is installed
12+
# deps is a data.frame with class "package_deps"
13+
deps <- deps[deps$package != "rJava", ]
14+
15+
# Install/Update the selected packages
16+
# The update() method for package_deps respects version requirements
17+
remotes::update(deps, upgrade = "always")

.devcontainer/setup.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Configuration
5+
AIR_VERSION="0.8.0"
6+
INSTALL_DIR="$HOME/.local/bin"
7+
mkdir -p "$INSTALL_DIR"
8+
9+
# Detect Architecture
10+
ARCH=$(uname -m)
11+
if [ "$ARCH" = "x86_64" ]; then
12+
AIR_ARCH="x86_64"
13+
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
14+
AIR_ARCH="aarch64"
15+
else
16+
echo "Unsupported architecture: $ARCH"
17+
exit 1
18+
fi
19+
20+
PLATFORM="unknown-linux-gnu"
21+
FILENAME="air-${AIR_ARCH}-${PLATFORM}.tar.gz"
22+
URL="https://github.com/posit-dev/air/releases/download/${AIR_VERSION}/${FILENAME}"
23+
24+
echo "Installing Posit Air CLI version ${AIR_VERSION} for ${AIR_ARCH}..."
25+
26+
# Download and install
27+
# We use a temporary directory to ensure clean cleanup
28+
TMP_DIR=$(mktemp -d)
29+
curl -LsSf "$URL" -o "${TMP_DIR}/${FILENAME}"
30+
tar -xzf "${TMP_DIR}/${FILENAME}" -C "$TMP_DIR"
31+
mv "${TMP_DIR}/air" "$INSTALL_DIR/air"
32+
rm -rf "$TMP_DIR"
33+
34+
# Ensure air is on PATH for the remainder of this setup script.
35+
export PATH="$INSTALL_DIR:$PATH"
36+
37+
# Verify Air CLI installation
38+
if ! command -v air &> /dev/null; then
39+
echo "Error: Air CLI failed to install or is not in PATH."
40+
exit 1
41+
fi
42+
echo "Air CLI installed successfully: $(air --version)"
43+
44+
# Install R dependencies
45+
echo "Installing R dependencies (excluding rJava)..."
46+
Rscript .devcontainer/setup.R
47+
48+
echo "Setup complete!"

R/global_params.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ global_quiet_param <- function(quiet) {
1515
#' Documentation template for rJava path-locking behavior.
1616
#'
1717
#' @section rJava Path-Locking:
18-
#' **Important for rJava Users**: This function sets environment variables
19-
#' (JAVA_HOME, PATH) that affect both command-line Java tools and rJava initialization.
20-
#' However, due to rJava's path-locking behavior when \code{\link[rJava]{.jinit}} is called
18+
#' **Important for \emph{rJava} Users**: This function sets environment variables
19+
#' (JAVA_HOME, PATH) that affect both command-line Java tools and \emph{rJava} initialization.
20+
#' However, due to \emph{rJava}'s path-locking behavior when \code{\link[rJava]{.jinit}} is called
2121
#' (see \url{https://github.com/s-u/rJava/issues/25}, \url{https://github.com/s-u/rJava/issues/249}, and \url{https://github.com/s-u/rJava/issues/334}),
2222
#' this function must be called **BEFORE** \code{\link[rJava]{.jinit}} is invoked. Once \code{\link[rJava]{.jinit}}
2323
#' initializes, the Java version is locked for that R session and cannot be changed without restarting R.
2424
#'
2525
#' \code{\link[rJava]{.jinit}} is invoked (and Java locked) when you:
2626
#' \itemize{
2727
#' \item Explicitly call \code{library(rJava)}
28-
#' \item Load any package that imports rJava (which auto-loads it as a dependency)
28+
#' \item Load any package that imports \emph{rJava} (which auto-loads it as a dependency)
2929
#' \item Even just use IDE autocomplete with \code{rJava::} (this triggers initialization!)
30-
#' \item Call any rJava-dependent function
30+
#' \item Call any \emph{rJava}-dependent function
3131
#' }
3232
#'
33-
#' Once any of these happen, the Java version used by rJava for that session is locked in.
34-
#' For command-line Java tools that don't use rJava, this function can be called at any
33+
#' Once any of these happen, the Java version used by \emph{rJava} for that session is locked in.
34+
#' For command-line Java tools that don't use \emph{rJava}, this function can be called at any
3535
#' time to switch Java versions for subsequent system calls.
3636
#'
3737
#' @keywords internal

R/internal_utilities.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ java_check_current_rjava_version <- function() {
417417
#' @param temp_dir The directory where files were extracted.
418418
#' @return The path to the first non-hidden directory found.
419419
#' @keywords internal
420+
#' @noRd
420421
._find_extracted_dir <- function(temp_dir) {
421422
# Ignore hidden files like .DS_Store or AppleDouble files (._)
422423
all_files <- list.files(temp_dir, full.names = TRUE)

R/java_install.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ java_install <- function(
7373
arch <- parts[vapply(parts, function(x) x %in% architectures, logical(1))][1]
7474
platform <- parts[vapply(parts, function(x) x %in% platforms, logical(1))][1]
7575

76-
# Create a symlink in the project directory (new structure with distribution/backend)
76+
77+
# Create a symlink in the project directory
7778
project_version_path <- file.path(
7879
project_path,
7980
"rjavaenv",

man/java_ensure.Rd

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/java_env_set.Rd

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rjava_path_locking_note.Rd

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)