Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "s3_website" issue while pushing Jekyll site on CloudFront through gitlab CI/CD?

I have created Pipeline in GitLabs and I am using docker as gitlab-runner. I want to push Jekyll website on s3 website. And to do so, I am using s3_website gem. I have 4 stages defined in my pipeline. Where I am building Jekyll, creating Artifacts using Gulp, executing test on my jekyll site and then deploying.

All steps are working fine but while doing deployment, I'm getting following error. And i could not figure it how to get this solve.

[fail] Could not load the site: Failed to parse ERB in /builds/myproject/s3_website.yml:
       (SyntaxError) /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_warn.rb:15: syntax error, unexpected tLABEL
           module_function define_method(:warn) {|*messages, uplevel: nil|

It is working perfectly fine on my local machine when I'm not on Docker. But when I try to do the same thing using docker. It is giving me above error.

I tried it with ruby 2.3, 2.4, 2.5, 2.6 on my docker machine. However no luck.

bundle exec s3_website push

I am expecting this to deploy the site on S3 bucket and corresponding cloudfront.

Any clue would be appreciated.

like image 754
Terry Avatar asked Jan 14 '19 04:01

Terry


1 Answers

We ran into this same error on CircleCI. If I understand correctly, the s3_website gem wraps a Java .jar that's using JRuby 1.7, and something must have changed in one of the Docker images or Ruby gems that causes it to start inheriting the system's Ruby 2+ path. As a result, its JRuby 1.7 tries to load Ruby gems that only work in Ruby 2.0 and above, so it runs into errors.

As a workaround, instead of letting the s3_website gem invoke the .jar file itself, I tell the s3_website gem to only download the .jar file, then I manually invoke it:

bundle exec s3_website install
java -cp $(bundle show s3_website)/*.jar s3.website.Push

I reported this on the s3_website project's GitHub page.

like image 173
Josh Kelley Avatar answered Nov 04 '22 04:11

Josh Kelley