-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Java binary with long classpath fails on read-only file system #6289
Copy link
Copy link
Closed
Labels
Description
Description of the problem / feature request:
When a Java binary's classpath is too long, the wrapper script creates manifest and jar
files containing the classpath. The wrapper writes these files to the directory containing
the wrapper. This fails when the binary is run from a read-only file system.
Feature requests: what underlying problem are you trying to solve with this feature?
Allowing a Bazel compiled Java binary or test to run from a read-only file system or from
a directory that's not writable.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Run a Java binary or test with a classpath that exceeds the limit (roughly 120K) on a read-only
file system.
What operating system are you running Bazel on?
Linux
What's the output of bazel info release?
development version
If bazel info release returns "development version" or "(@Non-Git)", tell us how you built Bazel.
bazel build src:bazel-bin
The version with the bug is 0.15.0
What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
The following patch to the wrapper should fix the problem.
***************
*** 303,313 ****
done
unset IFS
- RAND_ID=$(cat /dev/urandom | head -c 128 | md5func)
# Create manifest file
! MANIFEST_FILE="${self}-${RAND_ID}.jar_manifest"
!
! echo "Manifest-Version: 1.0" >$MANIFEST_FILE
CLASSPATH_LINE="Class-Path:$MANIFEST_CLASSPATH"
# No line in the MANIFEST.MF file may be longer than 72 bytes.
# A space prefix indicates the line is still the content of the last attribute.
--- 303,311 ----
done
unset IFS
# Create manifest file
! MANIFEST_FILE=$(mktemp)
! echo "Manifest-Version: 1.0" > "$MANIFEST_FILE"
CLASSPATH_LINE="Class-Path:$MANIFEST_CLASSPATH"
# No line in the MANIFEST.MF file may be longer than 72 bytes.
# A space prefix indicates the line is still the content of the last attribute.
***************
*** 316,327 ****
if (($i == 0)); then
PREFIX=""
fi
! echo "$PREFIX${CLASSPATH_LINE:$i:71}" >>$MANIFEST_FILE
done
! echo "Created-By: Bazel" >>$MANIFEST_FILE
# Create classpath JAR file
! MANIFEST_JAR_FILE="${self}-${RAND_ID}-classpath.jar"
if is_windows; then
MANIFEST_JAR_FILE="$(cygpath --windows "$MANIFEST_JAR_FILE")"
MANIFEST_FILE="$(cygpath --windows "$MANIFEST_FILE")"
--- 314,325 ----
if (($i == 0)); then
PREFIX=""
fi
! echo "$PREFIX${CLASSPATH_LINE:$i:71}" >> "$MANIFEST_FILE"
done
! echo "Created-By: Bazel" >> "$MANIFEST_FILE"
# Create classpath JAR file
! MANIFEST_JAR_FILE=$(mktemp)
if is_windows; then
MANIFEST_JAR_FILE="$(cygpath --windows "$MANIFEST_JAR_FILE")"
MANIFEST_FILE="$(cygpath --windows "$MANIFEST_FILE")"Reactions are currently unavailable