Gradlew Wrapper: Gradle Build daemon crashes if the environment variables contain non-ASCII characters


(Tamas Papik) #1

Hey there!

Like in the GH Issue below, successfully fixed gradle(/usr/bin/gradle) calls by setting locale to *.UTF-8 however anyhow I try gradle wrapper still crashes on Ubuntu 18.04. (Working fine on Ubuntu 16.04) All the info is in the issue below, but for our records:
Dockerfile:

FROM ubuntu:18.04

RUN dpkg --add-architecture i386
RUN apt-get update && apt-get upgrade && apt-get install -y --no-install-recommends apt-utils

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y openjdk-8-jdk libc6:i386 libstdc++6:i386 libgcc1:i386 libncurses5:i386 libz1:i386 wget unzip git

RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
	&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.UTF-8

ENV ANDROID_HOME /opt/android-sdk-linux

RUN cd /opt \
    && wget -q https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip -O android-sdk-tools.zip \
    && unzip -q android-sdk-tools.zip -d ${ANDROID_HOME} \
    && rm android-sdk-tools.zip

ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools

RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;25.0.2"

RUN git clone https://github.com/trapacska/intro_android_demo.git proj && cd proj && TEST="🦄" ./gradlew -i dependencies

The error is:

Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip
.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap/gradle-3.3-all.zip to /root/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap/gradle-3.3/bin/gradle
Initialized native services in: /root/.gradle/native
Removing 0 daemon stop events from registry
Starting a Gradle Daemon (subsequent builds will be faster)
Starting daemon process: workingDir = /root/.gradle/daemon/3.3, daemonArgs: [/usr/lib/jvm/java-8-openjdk-amd64/bin/java, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8, -Duser.country=US, -Duser.language=en, -Duser.variant, -cp, /root/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap/gradle-3.3/lib/gradle-launcher-3.3.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 3.3]
Starting process 'Gradle build daemon'. Working directory: /root/.gradle/daemon/3.3 Command: /usr/lib/jvm/java-8-openjdk-amd64/bin/java -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /root/.gradle/wrapper/dists/gradle-3.3-all/2n0i7hqatcbtk57vvql575dbap/gradle-3.3/lib/gradle-launcher-3.3.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 3.3
Successfully started process 'Gradle build daemon'
An attempt to start the daemon took 0.912 secs.
Connected to daemon DaemonInfo{pid=45, address=[48ce2503-0195-4612-8698-70421948fe13 port:33919, addresses:[/127.0.0.1]], state=Busy, lastBusy=1531918461997, context=DefaultDaemonContext[uid=e7afc6f8-7251-495f-a0d4-dfa61a7da878,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/root/.gradle/daemon,pid=45,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]}. Dispatching request Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}.
Received result org.gradle.launcher.daemon.protocol.BuildStarted@4c9cce17 from daemon DaemonInfo{pid=45, address=[48ce2503-0195-4612-8698-70421948fe13 port:33919, addresses:[/127.0.0.1]], state=Busy, lastBusy=1531918461997, context=DefaultDaemonContext[uid=e7afc6f8-7251-495f-a0d4-dfa61a7da878,javaHome=/usr/lib/jvm/java-8-openjdk-amd64,daemonRegistryDir=/root/.gradle/daemon,pid=45,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]} (build should be starting).
The message received from the daemon indicates that the daemon has disappeared.
Build request sent: Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}
Attempting to read last messages from the daemon log...
Daemon pid: 45
  log file: /root/.gradle/daemon/3.3/daemon-45.out.log
----- Last  20 lines from daemon log file - daemon-45.out.log -----
12:54:22.135 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] stopOnExpiration() called on daemon
12:54:22.138 [DEBUG] [org.gradle.launcher.daemon.server.Daemon] awaitExpiration() called on daemon
12:54:22.139 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon is running. Sleeping until state changes.
12:54:22.230 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 13: received class org.gradle.launcher.daemon.protocol.Build
12:54:22.231 [DEBUG] [org.gradle.launcher.daemon.server.DefaultDaemonConnection] thread 13: Received non-IO message from client: Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}
12:54:22.231 [INFO] [org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler] Received command: Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}.
12:54:22.231 [DEBUG] [org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler] Starting executing command: Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj} with connection: socket connection from /127.0.0.1:33919 to /127.0.0.1:54070.
12:54:22.234 [ERROR] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] Command execution: started DaemonCommandExecution[command = Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}, connection = DefaultDaemonConnection: socket connection from /127.0.0.1:33919 to /127.0.0.1:54070] after 0.0 minutes of idle
12:54:22.235 [INFO] [org.gradle.launcher.daemon.server.DaemonRegistryUpdater] Marking the daemon as busy, address: [48ce2503-0195-4612-8698-70421948fe13 port:33919, addresses:[/127.0.0.1]]
12:54:22.236 [DEBUG] [org.gradle.launcher.daemon.registry.PersistentDaemonRegistry] Marking busy by address: [48ce2503-0195-4612-8698-70421948fe13 port:33919, addresses:[/127.0.0.1]]
12:54:22.237 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Waiting to acquire exclusive lock on daemon addresses registry.
12:54:22.237 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Lock acquired.
12:54:22.239 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on daemon addresses registry.
12:54:22.239 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] resetting idle timer
12:54:22.239 [DEBUG] [org.gradle.launcher.daemon.server.DaemonStateCoordinator] daemon is running. Sleeping until state changes.
12:54:22.240 [INFO] [org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy] Daemon is about to start building Build{id=6430b774-bce4-49e9-89ca-64d02e75f3f5.1, currentDir=/proj}. Dispatching build started information...
12:54:22.241 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 16: dispatching class org.gradle.launcher.daemon.protocol.BuildStarted
12:54:22.255 [DEBUG] [org.gradle.launcher.daemon.server.SynchronizedDispatchConnection] thread 13: received class org.gradle.launcher.daemon.protocol.CloseInput
12:54:22.255 [DEBUG] [org.gradle.launcher.daemon.server.DefaultDaemonConnection] thread 13: Received IO message from client: org.gradle.launcher.daemon.protocol.CloseInput@61637a08
12:54:22.256 [DEBUG] [org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment] Configuring env variables: {PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/tools/bin:/opt/android-sdk-linux/platform-tools, HOSTNAME=ec81a79c2337, TEST=🦄, OLDPWD=/proj, PWD=/proj, LANG=en_US.UTF-8, SHLVL=0, HOME=/root, ANDROID_HOME=/opt/android-sdk-linux}
----- End of the daemon log -----


FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

Thanks in advance!


(Tamas Papik) #2

Seems like because gradle daemon crashes at a point of getting the envs, it can’t read the LANG env itself as well… Any help please?