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

Ruby 2.5.0 #421

Open
inopinatus opened this issue Dec 28, 2017 · 8 comments
Open

Ruby 2.5.0 #421

inopinatus opened this issue Dec 28, 2017 · 8 comments

Comments

@inopinatus
Copy link

inopinatus commented Dec 28, 2017

Ruby 2.5.0 was released on 2017-12-25 with new features and performance improvements. https://www.ruby-lang.org/en/news/2017/12/25/ruby-2-5-0-released/

Please support Ruby 2.5.x.

@porter77
Copy link

porter77 commented Apr 6, 2018

+1

1 similar comment
@osulyanov
Copy link

+1

@AlexanderUlitin
Copy link

+1, Ruby 2.3 is pretty old now and a lot of people need new Ruby versions on OpsWorks!

@timdorr
Copy link

timdorr commented Sep 21, 2018

I'll repost my instructions for 2.4 on OpsWorks below. We're looking at rolling out 2.5 support soon, so I'll update this comment if things change. For the most part, s/2.4.1/2.5.1/ the contents below.

BTW, please don't post "+1" comments. They don't add any value to the issue thread and just bug every other commenter here. Use the 👍 reaction on the OP above. That will also cause this thread to sort to the top of the most reacted issues on this repo.


(Note: This is only for Ubuntu 14.04. Other OSes are on your own...)

I was able to get this to work on my own. I had to do a few things.

First, you need a .deb for Ruby 2.4.1. In order to figure this out, I downloaded the Ruby 2.3.4 .deb, extracted it (.debs are .ar files with a control.tar.gz and data.tar.gz inside), and opened up the usr/local/lib/ruby/2.3.0/x86_64-linux/rbconfig.rb file. That contains the exact configure args (CONFIG["configure_args"]) that were used to build Ruby. I used that to build my own copy of 2.4.1 on a x86_64 Ubuntu 14.04 box:

apt-get install gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
wget https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.gz
tar zxfv ruby-2.4.1.tar.gz
cd ruby-2.4.1/
./configure --prefix=/usr/local --enable-shared --disable-rpath --disable-install-doc
make

I noticed the deb was built with fpm, so I installed that to do my eventual packaging:

apt-get install ruby ruby-dev
gem install --no-ri --no-rdoc fpm

One last thing I needed to duplicate the build was to get the right post-install script. I created a postinstall file with these contents:

#! /usr/bin/env sh
/sbin/ldconfig

OK, so now we're ready to package things up.

make install DESTDIR=/tmp/installdir/
fpm -s dir -t deb -n opsworks-ruby2.4 -v 2.4.1-1 -C /tmp/installdir --after-install=./postinstall

Out pops a opsworks-ruby2.4_2.4.1-1_amd64.deb file for you to use. You can use dpkg -c opsworks-ruby2.4_2.4.1-1_amd64.deb to make sure it's got the right stuff in it. Here's a copy of my build that we're using in production. Use this at your own risk, as I may have messed something up!

https://www.dropbox.com/s/1hjlnj6x0lco0d6/opsworks-ruby2.4_2.4.1-1_amd64.deb?dl=0

To actually use this, you need to get OpsWorks to download from a URL you control. The default URL can be overridden via stack JSON. So, create an S3 bucket and upload the .deb under a packages/ubuntu/14.04/ folder. (Don't forget to make the bucket/files public!) Then add this to your stack JSON:

  "opsworks_commons": {
    "assets_url": "https://my-opsworks-bucket-o-stuff.s3.amazonaws.com"
  },

To ensure you don't break things if you don't update the ruby version right away, you can also place the other .debs that OpsWorks pre-built into that bucket at that path. They're available at https://opsworks-instance-assets.s3.amazonaws.com/packages/ubuntu/14.04/opsworks-ruby2.3_2.3.4-1_amd64.deb and you can adjust the URL to grab ones for other versions of Ruby that you have in use currently.

OK, last part is to get OpsWorks to use this version of Ruby. While they don't have a preset for 2.4, you can configure it yourself. So, add this to your stack JSON:

  "ruby" : {
    "major_version": "2",
    "minor_version": "4",
    "patch_version": "1",
    "pkgrelease": "1",
    "full_version": "2.4",
    "version": "2.4.1"
  },

That will override whatever version you have set for your layer. You should be able to deploy and be on 2.4!

It worked for me, but obviously I can't guarantee success for others. Also, if you have other layer types that depend on other binaries (Node, PHP, etc, and probably MySQL/Memcached too), you'll need to upload those .debs to your bucket as well (since you're overriding the assets_url for the whole stack).

TL;DR I built a custom binary .deb for Ruby 2.4.1, hosted that on an S3 bucket, and configured my stack JSON to use that binary and ruby version.

@timdorr
Copy link

timdorr commented Sep 25, 2018

Even better, here's a Dockerfile to build it with:

FROM debian:jessie

RUN apt-get update && apt-get install -y \ 
    gcc \
    autoconf \
    bison \
    build-essential \
    libssl-dev \
    libyaml-dev \
    libreadline6-dev \
    zlib1g-dev \
    libncurses5-dev \
    libffi-dev \
    libgdbm3 \
    libgdbm-dev \
    ruby \
    ruby-dev \
    rubygems \
    wget

RUN gem install --no-ri --no-rdoc fpm

WORKDIR /tmp

ADD postinstall .

RUN wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz && \
    tar zxfv ruby-2.5.1.tar.gz && \
    cd ruby-2.5.1/ && \
    ./configure --prefix=/usr/local --enable-shared --enable-install-static-library --disable-rpath --disable-install-doc && \
    make && \
    make install DESTDIR=/tmp/installdir/
    
RUN fpm -s dir -t deb \
        -n opsworks-ruby2.5 -v 2.5.1-1 \
        --maintainer "My Company <https://www.example.com>" \
        --url "http://www.ruby-lang.org" \
        --description "A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write." \
        --license "SBSD (http://www.ruby-lang.org/en/about/license.txt)" \
        -C /tmp/installdir \
        --after-install=./postinstall

Just make sure you have that postinstall file in place above.

This was referenced Nov 5, 2018
@Allan-W-Smith
Copy link

Allan-W-Smith commented May 24, 2019

(Note: This is only for Ubuntu 14.04. Other OSes are on your own...)

For those looking to replicate this method on Amazon Linux 2017.03 you can follow the steps to the tee, except use:

fpm -s dir -t rpm -n opsworks-ruby24 -v 2.4.1 -C /tmp/installdir --after-install=./postinstall

instead of:

fpm -s dir -t deb -n opsworks-ruby2.4 -v 2.4.1-1 -C /tmp/installdir --after-install=./postinstall

Also don't forget to use the correct folder target in your S3 bucket:

https://s3-your-region.amazonaws.com/your-bucket/packages/amazon/2017.03/opsworks-ruby24-2.4.3-1.x86_64.rpm

Side note: I did this successfully with Ruby 2.6.3 rather than 2.4.1 as mentioned. Required an update of glibc/libc6 version on my server but you could alternatively compile with the matching version locally rather than updating your server. (in my case matching version was glibc-2.17)

@aka47
Copy link

aka47 commented Jun 27, 2019

I followed the instructions from @timdorr just for ruby 2.6.3 .. and it worked .. the debian package name is opsworks-ruby2.6_2.6.3-1_amd64.deb

You can use it with that stack json..

 "opsworks_commons": {
       "assets_url": "https://jovoto-developer.s3.eu-central-1.amazonaws.com"
   },
   "ruby": {
       "major_version": "2",
       "minor_version": "6",
       "patch_version": "3",
       "pkgrelease": "1",
       "full_version": "2.6",
       "version": "2.6.3"
   },

And I also needed to set the passenger_gem path in the stack settings ..

    "passenger": {
        "gems_path": "/usr/local/lib/ruby/gems/2.6.0/gems"
    },

Somehow in the UI of opsworks I can select ruby 2.6 from the dropdown, but it doesn't work yet for me.. :(

@interpegasus
Copy link

Ruby 3.0 released 25 Dec 2020

https://www.ruby-lang.org/en/news/2020/12/25/ruby-3-0-0-released/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants