rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
10.83k stars 535 forks source link

Is Java 8 still sufficient for BFG? #465

Closed je-hal closed 2 years ago

je-hal commented 2 years ago

Hi,

I use WSL2 on Windows 10 to run Ubuntu.

On Windows, downloaded the BFG jar (1.14.0) in and installed JRE 1.8.0_311. Then I moved the JAR file to /usr/local/bin on WSL2.

Executing java.exe from WSL2 works fine:

$ java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)

However, executing bfg brings up an error:

$ alias bfg='java -jar /usr/local/bin/bfg-1.14.0.jar'
$ bfg -version
Error: Could not find or load main class use.newer.java.Version8

Sounds to me as if Java 8 is no longer sufficient to execute BFG, although it says in the Requirements section of the documentation that Java 8 should do:

The Java Runtime Environment (Java 8 or above

Is there a specific java 8 version required? Thanks

rtyley commented 2 years ago

Thanks for reporting the problem. Java 8 currently is sufficient to run the BFG (tho', as a side note, I'd recommend Java 11 as Java 8 is EOL). I've just verified this now (executed under Ubuntu Linux 20.04, not under WSL or Windows):

$ wget https://repo1.maven.org/maven2/com/madgag/bfg/1.14.0/bfg-1.14.0.jar

$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -version
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-8u312-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)

$ /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -jar bfg-1.14.0.jar
bfg 1.14.0
Usage: bfg [options] [<repo>]
...

A small note - the BFG does not have a -version option, so when you ran:

bfg -version

...I would see this output, starting with a Unknown option error:

Error: Unknown option -version
bfg 1.14.0
Usage: bfg [options] [<repo>]
...

...but you saw:

Error: Could not find or load main class use.newer.java.Version8

That's a pretty surprising error. The BFG uses https://github.com/rtyley/use-newer-java to attempt to give a user-friendly error if the user is using a version of Java that is older than Java 8. However, on your system, Java is not even finding the class called use.newer.java.Version8.

If you use jar -tvf bfg-1.14.0.jar to list the contents of the jar file, do you see the compiled class file? This is what I see - the class file that is normally the first thing that's executed:

$ jar -tvf bfg-1.14.0.jar  | grep Version8
   508 Sun Jan 07 22:20:02 GMT 2018 use/newer/java/Version8.class

If you want to bypass the Java-version check, you can use -cp and specify the main BFG class:

java -cp bfg-1.14.0.jar com.madgag.git.bfg.cli.Main
je-hal commented 2 years ago

@rtyley Thank you for the quick response (and for the hint with the non-existing -version option).

I now use the following working installation:

In this constellation, it works.

Although I was able to execute java.exe installed on Windows from WSL2, I always ended up with the error above (use.newer.java.Version8), no matter what I tried. Probably it's a problem with the Java environment variables - I dug into it (If someone else would like to give it a try, see how to Share Environment Vars between WSL and Windows), but gave up in the end.