DEV Community

Cover image for Upgrade to Ruby 3 - update projects πŸ”©
Michael Currin
Michael Currin

Posted on

Upgrade to Ruby 3 - update projects πŸ”©

Now, you should have Ruby 3 ready.

Your Ruby projects will have stale gems and lockfiles though, so you need to make changes to them.

I'm going to walk you through how to update your projects to get them using Ruby 3. This will be similar across projects but I will focus on Jekyll projects. I like to build websites using Jekyll as a static site generator. I have a demo here if you are interest - including an update to the Gemfile to support Ruby 3.

Repeat the steps below for each Ruby project of yours.

Remove old gems πŸ™…β€β™‚οΈ πŸ’Ž

$ rm -rf vendor
Enter fullscreen mode Exit fullscreen mode

This is not strictly necessary, as 2.7 and 3.0 gems are kept in separate directories in the vendor directory. But if you are never going to use those old gems again, then you can reclaim some space now.

Remove lockfile πŸ™…β€β™‚οΈ πŸ—ƒ

$ rm Gemfile.lock
Enter fullscreen mode Exit fullscreen mode

I found that that I got errors running Jekyll, unless I dropped the old lockfile and started over with a fresh set of the latest gems.

Install gems

$ bundle install
Enter fullscreen mode Exit fullscreen mode

Then commit your lockfile.

Install missing gems πŸš› πŸ“¦

For Jekyll in Ruby 3, you'll get this error on serving.

Load error: cannot load such file – webrick
Enter fullscreen mode Exit fullscreen mode

Fix that by installing Webrick, as per Jekyll issue #8523. Perhaps this will be fixed in newer releases of Jekyll.

Run this to add the gem to your Gemfile and install it.

$ bundle add webrick
Enter fullscreen mode Exit fullscreen mode

Commit your lockfile.

Start Jekyll

Your Jekyll site should be ready to use now.

$ bundle exec jekyll serve --trace
Enter fullscreen mode Exit fullscreen mode

Thanks for reading. I hope that eases your journey to using Ruby 3.

Credits πŸ“Έ

Cover image created with Google Jamboard.

Photo by Joshua Fuller on Unsplash

Top comments (1)

Collapse
 
fenix profile image
Fenix

Sure... ThX again for sharing Michael.