Fixing s3_website Java 9 Error with jEnv

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$.rubyRuntime$lzycompute(Ruby.scala:4) 	at$.rubyRuntime(Ruby.scala:4) 	at$$anonfun$15.apply(Config.scala:229) 	at$$anonfun$15.apply(Config.scala:227) 	at scala.util.Try$.apply(Try.scala:192) 	at$.erbEval(Config.scala:227) 	at$$anonfun$2.apply(Site.scala:28) 	at$$anonfun$2.apply(Site.scala:27) 	at scala.util.Success.flatMap(Try.scala:231) 	at$.parseConfig(Site.scala:27) 	at$.loadSite(Site.scala:100) 	at$.push(Push.scala:62) 	at$.main(Push.scala:40) 	at Caused by: java.lang.RuntimeException: unsupported Java version: 9 	at org.jruby.RubyInstanceConfig.initGlobalJavaVersion( 	at org.jruby.RubyInstanceConfig.( 	... 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.

Leave a Reply