3

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.

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
yuji
  • 31
  • 1
  • 1
  • 2
  • Im using 1.9.2 and Rake 0.8.7 Same error. Changed Rake to 0.9.6 and same error also. – Evolve Mar 13 '13 at 07:00
  • possible duplicate of [undefined method \`source\_index' for Gem:Module (NoMethodError)](http://stackoverflow.com/questions/15349869/undefined-method-source-index-for-gemmodule-nomethoderror) – sab Aug 23 '13 at 22:20

5 Answers5

5

the problem is perfectly solved undefined method `source_index' for Gem:Module (NoMethodError) with only simple row

gem update --system 1.8.25
Community
  • 1
  • 1
sab
  • 651
  • 8
  • 17
1

Ok Ive been messing with this all day and finally got things working for me with the following:

  1. Bring RVM up-to-date

    rvm get head

  2. Change ruby version to 1.9.3

    • Update in Gemfile
    • Update .rvmrc file
  3. 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?

Evolve
  • 8,939
  • 12
  • 51
  • 63
0

From ApiDock:

This class is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

In the question, Rails version 2.3.17 is used and because of being deprecated, it gives an error. If it was 2.3.8, it could be worked.

ekremkaraca
  • 1,453
  • 2
  • 18
  • 37
  • I 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 #. 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' – yuji Mar 13 '13 at 02:34
  • Yep Im getting the same and scratching my head right now as to how to solve. – Evolve Mar 13 '13 at 06:49
0

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:

  1. gem install rubygems-update -v '1.8.25'
  2. gem uninstall rubygems-update # and just removed the other versions.

Didn't make a difference, but just sharing my findings.

Community
  • 1
  • 1
Evolve
  • 8,939
  • 12
  • 51
  • 63
  • The `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 run `rubygems_update` to actually commit the version as your `gem --version` – uxp Mar 13 '13 at 21:23
0

Update you gem to 1.8.25

gem update --system 1.8.25

This may help you.

Community
  • 1
  • 1
Amrit Dhungana
  • 4,371
  • 5
  • 31
  • 36