Search code examples
ruby-on-railsrubyrubygemsbundlergemfile

Rails not using modified gem instead of original


this is what I believe a simple problem I need help with. I'm trying to modify a gem's method so that I can add another argument to it. For this, I've cloned the gem's repo to a local directory and changed the code I needed. Inside my app's Gemfile I'm doing this:

gem 'recommendable', path: "/home/aristizabal95/forked_gems/recommendable"

And running bundle install afterwards. Even though the bundler says it's using my code, when I run the tests I get this error:

ArgumentError: wrong number of arguments (given 4, expected 1..3)
    from /var/lib/gems/2.3.0/gems/recommendable-2.2.0/lib/recommendable/rater/recommender.rb:21:in `recommended_for'

which indicates that the app is not running my version of the gem, but the original one. I have no idea why it's not working, and was unable to find any issue related to this.

Thanks in advance

EDIT: This is what the Gemfile.lock looks like

PATH
  remote: /home/aristizabal95/forked_gems/recommendable
  specs:
    recommendable (2.2.1)
    activesupport (>= 3.0.0)
    hooks (>= 0.2.1)
    redis (>= 2.2.0)
GEM
  recommendable!

Solution

  • My guess is that spring still has the gem from the original gem source loaded.

    To force spring to reload the gem (from your local source), do:

    spring stop
    

    in the console. Then restart your server and you should be using the gem from your local source.