Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ruby 2.6+ with jekyll/bundler #2565

Closed
daxenberger opened this issue Feb 3, 2022 · 11 comments
Closed

Using ruby 2.6+ with jekyll/bundler #2565

daxenberger opened this issue Feb 3, 2022 · 11 comments
Labels
archived This issue has been locked. backend-builds question Further information is requested

Comments

@daxenberger
Copy link

Please describe which feature you have a question about?

I am building a static website with a jekyll version that requires ruby 2.5+, but I haven't found a way to do so using the (default) linux:2 build image. Even though I explicitly specified the ruby version in the Gemfile, I only see

[WARNING]: Your Ruby version is 2.4.6, but your Gemfile specified 2.6.3
[ERROR]: !!! Build failed
[ERROR]: !!! Non-Zero Exit Code detected

I also tried setting VERSION_RUBY_DEFAULT in the pre-build settings without effect.

Provide additional details

The only way I managed to make it work was to set a custom build image. However, using a jekyll/builder image doesn't work at all (deployment fails at the Build step without any logs available), so I have to use the plain ruby image with a suitable version and gem install bundler jekyll in the pre-build settings at every build. This works, but significantly increases build time, so not really a satisfying solution.

What AWS Services are you utilizing?

Only working on the Amplify console.

Provide additional details e.g. code snippets

See above.

@daxenberger daxenberger added the question Further information is requested label Feb 3, 2022
@github-actions
Copy link

github-actions bot commented Feb 3, 2022

Hi 👋, thanks for opening! While we look into this...

If this issue is related to custom domains, be sure to check the custom domains troubleshooting guide to see if that helps. Also, there is a more general troubleshooting FAQ that may be helpful for other questions.

Lastly, please make sure you've specified the App ID and Region in the issue!

@ghost ghost self-assigned this Feb 3, 2022
@ghost ghost added the backend-builds label Feb 3, 2022
@ghost
Copy link

ghost commented Feb 3, 2022

Hi @daxenberger 👋🏽 thank you for raising this issue. We are investigating this and I will report back with an update.

@daxenberger
Copy link
Author

Any updates on this one? The issue persists ...

@RockManJoe64
Copy link

RockManJoe64 commented Oct 14, 2022

Any updates? I'm also going down this road where I need Ruby 2.7.x to support Jekyll 4.x.

I tried using a custom build image based on Ubuntu.

I was able to successfully build my site in a local docker container running my custom image.

root@d1a946cccbe6:/working/mysite_repo# bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users
on this machine.
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/............
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Fetching public_suffix 5.0.0
Installing public_suffix 5.0.0
Fetching addressable 2.8.1
Installing addressable 2.8.1
Using bundler 2.1.4
...
Bundle complete! 8 Gemfile dependencies, 35 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

But when I run it in AWS Amplify, it fails with this message:

                                 # Starting phase: preBuild
2022-10-14T03:47:37.362Z [INFO]: # Executing command: bundle install
2022-10-14T03:47:37.362Z [WARNING]: /codebuild/output/src390886491/src/mysite_repo/amplify.sh: line 13: bundle: command not found
2022-10-14T03:47:37.362Z [ERROR]: !!! Build failed
2022-10-14T03:47:37.362Z [ERROR]: !!! Non-Zero Exit Code detected
2022-10-14T03:47:37.363Z [INFO]: # Starting environment caching...
2022-10-14T03:47:37.363Z [INFO]: # Environment caching completed
Terminating logging...

Any ideas why?

@RockManJoe64
Copy link

RockManJoe64 commented Oct 15, 2022

I may have found an answer. I modified my build's amplify.yaml to the following.
Seems that adding the actual rbenv init command helped, along with setting up the ruby version before building.

In the future, to upgrade to a later ruby version, I can either rebuild the image, or add the command to install the latest ruby version in the amplify.yaml. But the latter would increase the build time, so I think I'll just rebuild the image 😉

version: 1
env:
  variables:
    JEKYLL_ENV: production
frontend:
  phases:
    preBuild:
      commands:
        - eval "$(/root/.rbenv/bin/rbenv init - bash)"
        - rbenv global 2.7.1
        - gem install bundler
        - bundle install
    build:
      commands:
        - bundle exec jekyll build
  artifacts:
    baseDirectory: _site
    files:
      - '**/*'
  cache:
    paths: []

@EdjeElectronics
Copy link

Hi @hloriana , I am having the same issue trying to build my Jekyll website with AWS Amplify. It seems the build container is set up to use Ruby v2.6.3, but I need Ruby version 2.7.x or higher. I tried using @RockManJoe64 's solution, but the build log gives me a /root/.rbenv/bin/rbenv: No such file or directory error.

How can I set up the build environment to use a more recent version of Ruby?

@RockManJoe64
Copy link

Hi @hloriana , I am having the same issue trying to build my Jekyll website with AWS Amplify. It seems the build container is set up to use Ruby v2.6.3, but I need Ruby version 2.7.x or higher. I tried using @RockManJoe64 's solution, but the build log gives me a /root/.rbenv/bin/rbenv: No such file or directory error.

How can I set up the build environment to use a more recent version of Ruby?

Hey @EdjeElectronics so the yaml prebuild commands in my post only work with a custom build image I made. If you're using the base Amplify image then it won't work 😁

@EdjeElectronics
Copy link

Got it, thanks @RockManJoe64 ! I got the build to work by adding rvm install 3.1.3 and rvm use 3.1.3 to the build config:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - rvm install 3.1.3
        - rvm use 3.1.3
        - bundle install
    build:
      commands:
        - bundle exec jekyll build
  artifacts:
    baseDirectory: _site
    files:
      - '**/*'
  cache:
    paths: []

@ghost ghost removed their assignment Jul 7, 2023
@Jay2113
Copy link
Contributor

Jay2113 commented Mar 7, 2024

Hi everyone 👋 , Amplify Hosting now uses the Amazon Linux 2023 build image by default for newly deployed applications and it has ruby version 3.2.2 and jekyll version 4.3.2 installed with it.

For steps on how to update the build image for existing apps from Amazon Linux 2 to Amazon Linux 2023 refer to this blog post: https://aws.amazon.com/blogs/mobile/amazon-linux-2023-hosting/.

@Jay2113 Jay2113 closed this as completed Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Copy link

github-actions bot commented Mar 7, 2024

This issue has been automatically locked.

@github-actions github-actions bot added the archived This issue has been locked. label Mar 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived This issue has been locked. backend-builds question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants