Fixing s3_website Java 9 Error with jEnv

November 28, 2017
Category: TIL
Tags: Jekyll

When I updated to macOS High Sierra, a bunch of necessary stuff broke: Jekyll, Homebrew, Node.js, and a bunch of gems. s3_website, the tool I use to deploy my Jekyll site to S3, was one of the gems that just completely disappeared. When I went to reinstall it, I got an error that I didn’t have Java installed. Against my better judgment, I went to the URL listed and installed it. Then I ran s3_website push.

After about 30 seconds, I got an error saying that s3_website doesn’t work with Java 9, which was the most recent version at the link. And also the version you get with brew cask install java. Well, shit.

Exception in thread "main" java.lang.ExceptionInInitializerError
	at org.jruby.Ruby.newInstance(
	at scala.util.Try$.apply(Try.scala:192)
	at scala.util.Success.flatMap(Try.scala:231)
Caused by: java.lang.RuntimeException: unsupported Java version: 9
	at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(
	at org.jruby.RubyInstanceConfig.<clinit>(
	... 15 more

After lots of searching, I came across a kind soul on Github suggesting that we use jEnv to define which java environment to use in the directory.

When I first installed jenv, I couldn’t add versions to the tool. I kept getting this error:

ln: /usr/local/opt/jenv/versions/oracle64-9.0.1: No such file or directory

The fix is described here: Once I added version 8 as well, I switched to version 8 locally with this:

jenv local oracle64-

Then I opened a fresh Terminal window and ran s3_website again and everything pushed up to s3 without an issue.