Openfoodnetwork: Upgrade the Ruby version and Ruby gems

Created on 19 Oct 2018  路  18Comments  路  Source: openfoodfoundation/openfoodnetwork

As of 2018-10-18, this app has Ruby 2.1.5 (released 2014-11-13), Rails 3.2.22 (released June 16, 2015), nokogiri 1.6.8.1 (released October 03, 2016), and pg 0.21.0 (released June 12, 2017).

I will work on updating this app. I have experience upgrading the Adopt-A-Tree app (https://github.com/OpenTwinCities/adopt-a-tree).

tech debt

Most helpful comment

I looked that up recently as well. A Ruby 2.1 upgrade should be no problem as you said. I upgraded Fair Food to 2.2 and needed to add one Rails gem dependency (bug in our Rails). I also had to patch one spec because an array was returned in a different order. It was very easy.

All 18 comments

Hey there @jhsu802701, welcome to the Open Food Network!

We're very much aware that our ruby/rails versions are not current...however we aren't able to upgrade until we finish the project of upgrading Spree to version 2. Doing this will then clear the way to us being able to upgrade ruby/rails.

You can see the past attempts at this here: https://github.com/openfoodfoundation/openfoodnetwork/issues/1943
https://github.com/openfoodfoundation/openfoodnetwork/issues/635
https://github.com/openfoodfoundation/openfoodnetwork/issues/705

So for now I suggest closing this issue and perhaps having a look at what @dependabot-bot is listing out as dependencies if that's the kind of contribution you'd like to make to the repo. Or perhaps even better would be to join our slack channel and keep up to date on the spree upgrade (currently in progress with @luisramos0 and @sauloperez and @mkllnk and @HugsDaniel) process, so you can then take part in the subsequent updating of rails/ruby 馃槂

There are things that could be already adapted in our current versions that will work with future versions. Is this not correct?
"Write OFN in current ruby 2.1 in a way that the migration to ruby 2.3 will be a breeze."
"Write OFN in current rails 3.2 in a way that the migration to rails 4 will be a breeze."
Is this not a valid project we could open to the community?
I am making this question because I think this is a generic and interesting topic for the community to help out (unlike the complex spree upgrade!).
This is a question for other core devs.

I like @luisramos0`s approach. We can't upgrade yet, but we can prepare ourselves for the upgrade. It would be good to know what we need to change for upgrading.

I am making this question because I think this is a generic and interesting topic for the community to help out (unlike the complex spree upgrade!).

That's an interesting idea. Theoretically, this would remove a great barrier of entry to new Ruby contributors. There's no need to be fully aware of OFN's and Spree's data model but of Rails/Ruby changes and I assume that's a potentially bigger set of devs.

To my understadning

Write OFN in current ruby 2.1 in a way that the migration to ruby 2.3 will be a breeze.

It shouldn't require any action as Ruby upgrades are backward compatible although I don't know off the top of my head what 2.3 brings in. AFAIK Spree does not force a particular version (or maybe we remove that restriction), so we could consider upgrading it before we finish with Spree.

Write OFN in current rails 3.2 in a way that the migration to rails 4 will be a breeze.

I've been here already 馃檲 . This will indeed require refactoring some calls to ActiveRecord methods and possibly other changes to the Gemfile. Someone can start with the former if we prepare detailed and scoped issues. Upgrade guide: https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-3-2-to-rails-4-0

@jhsu802701 it might be interesting to take a quick look at upgrading pg. Whether the version is restricted and if not what are its implications 馃

Quick scan into the guide.

  • Update from put to patch. We have some uses:
> grep put config/routes/*
config/routes/admin.rb:        put :register
config/routes/admin.rb:      put :bulk_update, on: :collection
config/routes/admin.rb:      put :cancel, on: :member
config/routes/admin.rb:      put :pause, on: :member
config/routes/admin.rb:      put :unpause, on: :member
config/routes/admin.rb:      put :cancel, on: :member, format: :json
config/routes/admin.rb:      put :resume, on: :member, format: :json
config/routes/spree.rb:  put 'credit_cards/new_from_token', to: 'credit_cards#new_from_token'
config/routes/spree.rb:    put :cancel, on: :member
  • We use the assets group in the Gemfile.
  • vendor/plugins is unused and can be removed.
  • lots of ActiveRecord stuff needs updating, for example scopes syntax and find_by_* methods.
  • ...

A lot of things can't be done in Rails 3.2, but as @sauloperez mentioned, some of the ActiveRecord stuff can already be done.

The spree upgrade to rails 4 is only in spree 2.1 here

I created #3708 now to represent the upgrade to spree 2-1-0 together with the upgrade to rails 4.
Although there's some discussion about rails 4 in this issue we can keep this issue and it's title to represent the upgrade of ruby from 2.1.5 to ruby 2.2, is this ok for everyone?

I read a little about the ruby versions after 2.1.5, the only thing that clearly stands out from all the release notes from 2.1 (end of 2014) to 2.6 (end of 2018) is that every single version makes significant performance improvements. So, upgrading ruby version is not only moving to supported versions of ruby is also making OFN run faster, which means happier users or less money on servers for the same capacity.

This can be done at any time now: both rails 3.2 and rails 4.0 support ruby 2.2.

In terms of priority, I believe this can either be picked up by the community (anyone can try to move ofn to ruby 2.2) or we can put it in our tech debt backlog after the upgrade to spree 2-1-0 #3708.

In theory we can upgrade Ruby from 2.1.5 to 2.1.10 now without any hassle. Minor versions should all be compatible.

I had a quick try at upgrading to 2.2.x the other week but there were some issues.

could you list which ones @Matt-Yorkley I'd like to understand how hard it would be to upgrade. It's blocking few things and that will only exacerbate over time.

I looked that up recently as well. A Ruby 2.1 upgrade should be no problem as you said. I upgraded Fair Food to 2.2 and needed to add one Rails gem dependency (bug in our Rails). I also had to patch one spec because an array was returned in a different order. It was very easy.

was it the test gem or rake? Let's push it then 馃挭 !

We're currently upgrading from 2.1.5 to 2.1.9 as a simple trial run.

We should try upgrading to 2.2.x soon, which is a much bigger jump.

We need to learn from this upgrade and put the necessary automation/processes in place so upgrading becomes as easy as cake and get up to date soon both reliably and efficiently.

Shall we close this? I guess we're not upgrading Ruby further until Rails is upgraded?

We can probably close this now, but I might try bumping to 2.3.8 to see if it works...

Okay let's keep it open then. No prob

4518 is merged 馃帀

we are on Ruby 2.3.7 馃帀
We agreed that we cant upgrage ruby any further before we get to Rails 4.0 (in spree 2.1) or maybe even only after Rails 4.1 (rails 4.1 comes on spree 2.3, I dont think we will get there), that probably means we will be independent of Spree before we make another ruby upgrade.
So, I'd say we can close this.
Is this correct @Matt-Yorkley?

Was this page helpful?
0 / 5 - 0 ratings