Why is my rake call causing an 'undefined method `source_index`' error?
Solution 1
the problem is perfectly solved undefined method `source_index' for Gem:Module (NoMethodError) with only simple row
gem update --system 1.8.25
Solution 2
Ok Ive been messing with this all day and finally got things working for me with the following:
-
Bring RVM up-to-date
rvm get head
-
Change ruby version to 1.9.3
- Update in Gemfile
- Update .rvmrc file
-
Update Rails to latest 2.3 version
- Update in Gemfile
- Update in environments.rb
Did all that then ran
bundle exec rake db:migrate
There is some wierd conflict happening in Rails 2.3 with the latest ruby gems and an unknown x factor, which could include an issue in ruby 1.9.1 and 1.9.2?
Solution 3
This: undefined method `source_index' for Gem:Module (NoMethodError) says
Gem.source_index has been deprecated for a while, but since Rails 2.3 is not getting any updates except critical security patches, this will never get fixed. RubyGems v2.0 finally removed that method. Downgrade to any rubygems version prior to 2.0.0, like 1.8.25 to get the functionality back for now.
So my guess right now is it's something to do with Rails 2.3 conflicting with the current RubyGems. I did this:
- gem install rubygems-update -v '1.8.25'
- gem uninstall rubygems-update # and just removed the other versions.
Didn't make a difference, but just sharing my findings.
Related videos on Youtube
yuji
Updated on July 07, 2022Comments
-
yuji almost 2 years
I am trying to run
bundle exec rake db:migrate
then encountered the following error.bundle exec rake db:migrate --trace ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment rake aborted! undefined method `source_index' for Gem:Module C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:298:in `add_gem_load_paths' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:132:in `process' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/initializer.rb:113:in `run' C:/Program Files/chiliproject-3.7.0/config/environment.rb:42:in `<top (required)>' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `block in require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:547:in `new_constants_in' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-2.3.17/lib/active_support/dependencies.rb:182:in `require' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rails-2.3.17/lib/tasks/misc.rake:4:in `block in <top (required)>' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:185:in `each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain' C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' C:/Ruby193/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' C:/Ruby193/bin/rake:23:in `load' C:/Ruby193/bin/rake:23:in `<main>' Tasks: TOP => db:migrate => environment
This is the part encountering the error:
def self.add_frozen_gem_path @@paths_loaded ||= begin source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) Gem.clear_paths Gem.source_index = source_index # loaded before us - we can't change them, so mark them Gem.loaded_specs.each do |name, spec| @@framework_gems[name] = spec end true end end
I know this seems to be basic, but I have been searching over the internet and can't seem to find the answer.
-
yuji about 11 yearsI changed rails version to 2.3.8 in my gemfile and ran bundle install and some other stuff. After running db:migrate again, i got a new error: rake aborted! undefined method
autoload_paths' for #<Rails::Configuration:0x3b84658>. This is the part encountering the error: config.autoload_paths += %W( #{RAILS_ROOT}/app/sweepers ) . . . # Liquid drops config.autoload_paths += %W( #{RAILS_ROOT}/app/drops ) i commented them out and the error went back again to 'undefined method
source_index' for Gem:Module' -
Evolve about 11 yearsYep Im getting the same and scratching my head right now as to how to solve.
-
uxp about 11 yearsThe
rubygems_update
gem is kind of like a meta-installer. It installs the installer for the updater. Yes, remove all other versions of the gem and then you'll need to runrubygems_update
to actually commit the version as yourgem --version