Syl
Syl

Reputation: 3829

Replaced a gem by its git repo, nothing works

I used the gem enumerated_attribute; however, the gem is not up to date and for last version I must use the git repo.

So I changed my gemfile as follows:

#gem 'enumerated_attribute'
gem "edave-enumerated_attribute", :git => "https://github.com/edave/enumerated_attribute.git"

After that I ran bundle install which removed the gem and copied the repo.

Now the rail apps react as if enumerated is not installed:

undefined method `enum_attr' for #<Class:0xa90d1c0>

What did I miss?

Upvotes: 1

Views: 123

Answers (1)

Dave
Dave

Reputation: 797

I just encountered this exact issue. I found that I could not update to a forked version of a gem, having already installed the original gem. Using bundler, the new version is picked up properly, but the changes are not reflected in Rails.

The following command should resolve the problem:

rails plugin install https://github.com/edave/enumerated_attribute.git --force

I would also suggest doing the following, just to ensure you have the expected gem version in your local repository (outside of your Rails app):

  1. Uninstall the gem using gem uninstall <gem_name>
  2. Check out a copy of the source for the forked gem you wish to use
  3. Build the gem from source: gem build <gem_name.gemspec>
  4. Install the gem to your local repo: sudo gem install <gem_name-version.gem>

I found the details for these steps here: Installing a Gem Fork from GitHub Source.

Upvotes: 1

Related Questions