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(Ruby.java:266)
	at s3.website.Ruby$.rubyRuntime$lzycompute(Ruby.scala:4)
	at s3.website.Ruby$.rubyRuntime(Ruby.scala:4)
	at s3.website.model.Config$$anonfun$15.apply(Config.scala:229)
	at s3.website.model.Config$$anonfun$15.apply(Config.scala:227)
	at scala.util.Try$.apply(Try.scala:192)
	at s3.website.model.Config$.erbEval(Config.scala:227)
	at s3.website.model.Site$$anonfun$2.apply(Site.scala:28)
	at s3.website.model.Site$$anonfun$2.apply(Site.scala:27)
	at scala.util.Success.flatMap(Try.scala:231)
	at s3.website.model.Site$.parseConfig(Site.scala:27)
	at s3.website.model.Site$.loadSite(Site.scala:100)
	at s3.website.Push$.push(Push.scala:62)
	at s3.website.Push$.main(Push.scala:40)
	at s3.website.Push.main(Push.scala)
Caused by: java.lang.RuntimeException: unsupported Java version: 9
	at org.jruby.RubyInstanceConfig.initGlobalJavaVersion(RubyInstanceConfig.java:1878)
	at org.jruby.RubyInstanceConfig.<clinit>(RubyInstanceConfig.java:1585)
	... 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: https://github.com/gcuisinier/jenv/wiki/Trouble-Shooting. Once I added version 8 as well, I switched to version 8 locally with this:

jenv local oracle64-1.8.0.151

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

Find this post useful?

Buy me a coffeeBuy me a coffee