Skip to content

setup-r-dependencies: set JAVA_HOME on Windows runners from Java 21 env vars#1100

Open
jeroen with Copilot wants to merge 3 commits into
v2-branchfrom
copilot/set-java-home-windows
Open

setup-r-dependencies: set JAVA_HOME on Windows runners from Java 21 env vars#1100
jeroen with Copilot wants to merge 3 commits into
v2-branchfrom
copilot/set-java-home-windows

Conversation

Copilot AI commented Jul 23, 2026

Copy link
Copy Markdown

rJava builds on Windows can fail because JAVA_HOME is not set by default on GitHub-hosted runners. This updates setup-r-dependencies to export JAVA_HOME automatically from the runner’s Java 21 variables when it is missing.

  • Action behavior change (Windows only)

    • Added a dedicated Set JAVA_HOME (Windows) step in setup-r-dependencies/action.yaml.
    • When JAVA_HOME is unset, the step maps by runner arch:
      • X64JAVA_HOME_21_X64
      • ARM64JAVA_HOME_21_AARCH64
    • Leaves pre-set JAVA_HOME untouched.
    • Emits a warning for unexpected Windows architectures.
  • Docs update

    • Documented the new automatic Java configuration behavior in setup-r-dependencies/README.md.
- name: Set JAVA_HOME (Windows)
  if: ${{ runner.os == 'Windows' }}
  shell: bash
  run: |
    if [ -z "${JAVA_HOME:-}" ]; then
      arch="${RUNNER_ARCH^^}"
      case "${arch}" in
        X64) echo "JAVA_HOME=${JAVA_HOME_21_X64}" >> $GITHUB_ENV ;;
        ARM64) echo "JAVA_HOME=${JAVA_HOME_21_AARCH64}" >> $GITHUB_ENV ;;
      esac
    fi

Copilot AI linked an issue Jul 23, 2026 that may be closed by this pull request
@jeroen
jeroen marked this pull request as ready for review July 23, 2026 11:35
Copilot AI changed the title [WIP] Set JAVA_HOME environment variable for rJava package on Windows setup-r-dependencies: set JAVA_HOME on Windows runners from Java 21 env vars Jul 23, 2026
Copilot AI requested a review from jeroen July 23, 2026 11:35
@gaborcsardi

Copy link
Copy Markdown
Member

Thanks! Why doesn't this belong in setup-r?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set JAVA_HOME on Windows

3 participants