rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
697 stars 126 forks source link

regression: gradle --version fails in bash, runs well in cmd, on an ENV variable issue for JAVA_HOME, with #477

Open doctorpangloss opened 4 hours ago

doctorpangloss commented 4 hours ago

This issue is observed in busybox-w64u-PRE-5531-g0e958a72e.exe

This issue does not reproduce in

BusyBox v1.37.0-PRE-5288-ge960b0d69 (2024-01-31 08:44:10 GMT)

which lacks the fixes needed for chocolatey related to environment variables.

executing this script with C:/busybox64.exe bash -X ./check_install.sh

#!/busybox64.exe bash
set -eux

# test versions
java --version
echo $JAVA_HOME
echo $PATH
which java
java -XshowSettings:properties 2>&1 | grep 'java.home'
cmd.exe /c "gradle --version"
gradle --version

gradle --version fails where cmd.exe /c "gradle --version" succeeds

+ java --version
openjdk 21.0.2 2024-01-16
OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30)
OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)
C:\Java\graalvm-community-openjdk-21.0.2
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files\dotnet;C:\Users\ContainerAdministrator\.dotnet\tools;C:\Program Files\powershell;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\bin;C:\Program Files\PowerShell\7\;C:\Docker\docker;C:\Java\graalvm-community-openjdk-21.0.2\bin;C:\Java\graalvm-community-openjdk-21.0.2\lib\svm\bin;C:\Program Files\nodejs;C:\Gradle\gradle-8.10.1\bin;C:\Program Files\Go\bin;C:\Program Files\Amazon\AWSCLIV2;C:\Program Files\dotnet;C:\Users\ContainerAdministrator\AppData\Roaming\npm;C:\Users\ContainerAdministrator\go\bin
+ echo 'C:\Java\graalvm-community-openjdk-21.0.2'
+ echo 'C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program' 'Files\dotnet;C:\Users\ContainerAdministrator\.dotnet\tools;C:\Program' 'Files\powershell;C:\ProgramData\chocolatey\bin;C:\Program' 'Files\Git\bin;C:\Program' 'Files\PowerShell\7\;C:\Docker\docker;C:\Java\graalvm-community-openjdk-21.0.2\bin;C:\Java\graalvm-community-openjdk-21.0.2\lib\svm\bin;C:\Program' 'Files\nodejs;C:\Gradle\gradle-8.10.1\bin;C:\Program' 'Files\Go\bin;C:\Program' 'Files\Amazon\AWSCLIV2;C:\Program' 'Files\dotnet;C:\Users\ContainerAdministrator\AppData\Roaming\npm;C:\Users\ContainerAdministrator\go\bin'
+ which java
C:/Java/graalvm-community-openjdk-21.0.2/bin/java.exe
+ java -XshowSettings:properties
+ grep java.home
    java.home = C:\Java\graalvm-community-openjdk-21.0.2
+ cmd.exe /c 'gradle --version'

Welcome to Gradle 8.10.1!

Here are the highlights of this release:
 - Support for Java 23
 - Faster configuration cache
 - Better configuration cache reports

For more details see https://docs.gradle.org/8.10.1/release-notes.html

------------------------------------------------------------
Gradle 8.10.1
------------------------------------------------------------

Build time:    2024-09-09 07:42:56 UTC
Revision:      8716158d3ec8c59e38f87a67f1f311f297b79576

Kotlin:        1.9.24
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.14 compiled on August 16 2023
Launcher JVM:  21.0.2 (GraalVM Community 21.0.2+13-jvmci-23.1-b30)
Daemon JVM:    C:\Java\graalvm-community-openjdk-21.0.2 (no JDK specified, using current Java home)
OS:            Windows Server 2022 10.0 amd64
+ gradle --version

ERROR: JAVA_HOME is set to an invalid directory: C:\Java\graalvm-community-openjdk-21.0.2

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

You can install the prereqs by installing Chocolately and then using:

#!/busybox64.exe bash
set -eux
cd C:/install

add_path() {
  to_add=$1
  updated_path="${PATH};${to_add}"
  updated_path=$(echo "${updated_path}" | sed 's/\//\\/g')
  setx /M PATH "${updated_path}"
  export PATH="${updated_path}"
}

set_var() {
  var_to_add=$1
  value_to_add=$(echo "$2" | sed 's/\//\\/g')
  setx /M $var_to_add "${value_to_add}"
  export $var_to_add="${value_to_add}"
}

# graalvm
curl -sLO https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_windows-x64_bin.zip
unzip -q graalvm-community-jdk-21.0.2_windows-x64_bin.zip -d C:/Java
mv C:/Java/graalvm-community-openjdk-21.0.2+13.1/ C:/Java/graalvm-community-openjdk-21.0.2/
add_path "C:/Java/graalvm-community-openjdk-21.0.2/bin"
add_path "C:/Java/graalvm-community-openjdk-21.0.2/lib/svm/bin"
set_var JAVA_HOME 'C:\Java\graalvm-community-openjdk-21.0.2'
rm graalvm-community-jdk-21.0.2_windows-x64_bin.zip

# gradle
mkdir 'C:\Gradle'
curl -sLO https://services.gradle.org/distributions/gradle-8.10.1-all.zip
unzip -q gradle-8.10.1-all.zip -d 'C:\Gradle'
rm gradle-8.10.1-all.zip
add_path "C:/Gradle/gradle-8.10.1/bin"
ale5000-git commented 3 hours ago

@doctorpangloss From cmd.exe executing gradle would execute gradle.bat, instead from inside busybox it prefer the gradle file without extension.

doctorpangloss commented 2 hours ago

Hmm well it works correctly in a build from January so I think it has something to do with environment variables that I do not understand.