ruby-on-rails – `add_frozen_gem_path’:Gem的未定义方法`source_index’:模块(NoMethodError)或不推荐使用Gem.source_index

ruby-on-rails – `add_frozen_gem_path’:Gem的未定义方法`source_index’:模块(NoMethodError)或不推荐使用Gem.source_index,第1张

概述我使用rails 2.3.11, ruby-1.9.2-p320. 尝试运行脚本/服务器,但收到此错误: – system@admin:~/apps/app_name/trunk$script/server=> Booting WEBrick=> Rails 2.3.11 application starting on http://0.0.0.0:3000/home/system/.rvm 我使用rails 2.3.11,ruby-1.9.2-p320.
尝试运行脚本/服务器,但收到此错误: –

system@admin:~/apps/app_name/trunk$script/server=> Booting WEBrick=> Rails 2.3.11 application starting on http://0.0.0.0:3000/home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21:in `add_froZen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError)    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:298:in `add_gem_load_paths'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:132:in `process'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:113:in `run'    from /home/system/apps/app_name/trunk/config/environment.rb:9:in `<top (required)>'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:126:in `require'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:126:in `require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:182:in `block in require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:547:in `new_constants_in'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:182:in `require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/commands/server.rb:84:in `<top (required)>'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in `require'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:73:in `require'    from script/server:3:in `<main>'

然后我在SO上提到几个答案并从终端运行以下命令: –

system@admin:~/apps/app_name/trunk$gem update --system 1.8.25

现在我收到错误: –

system@admin:~/apps/app_name/trunk$script/server=> Booting WEBrick=> Rails 2.3.11 application starting on http://0.0.0.0:3000NOTE: Gem.source_index is deprecated,use Specification. It will be removed on or after 2011-11-01.Gem.source_index called from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:21.NOTE: Gem::SourceIndex#refresh! is deprecated with no replacement. It will be removed on or after 2011-11-01.Gem::SourceIndex#refresh! called from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:34.NOTE: Gem::SourceIndex#load_gems_in is deprecated with no replacement. It will be removed on or after 2011-11-01.Gem::SourceIndex#load_gems_in called from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:322.NOTE: Gem::SourceIndex#add_spec is deprecated,use Specification.add_spec. It will be removed on or after 2011-11-01.Gem::SourceIndex#add_spec called from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:127.NOTE: Gem::SourceIndex#add_spec is deprecated,use Specification.add_spec. It will be removed on or after 2011-11-01.Gem::SourceIndex#add_spec called from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:127.NOTE: Gem::SourceIndex#initialize is deprecated with no replacement. It will be removed on or after 2011-11-01.Gem::SourceIndex#initialize called from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/vendor_gem_source_index.rb:100./home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:277:in `==': undefined method `name' for "actionmailer":String (NoMethodError)    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:217:in `==='    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:217:in `block in matching_specs'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:412:in `block in each'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:411:in `each'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:411:in `each'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:216:in `find_all'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:216:in `matching_specs'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:238:in `to_specs'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems.rb:1231:in `gem'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/rails/gem_dependency.rb:75:in `add_load_paths'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:301:in `block in add_gem_load_paths'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:301:in `each'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:301:in `add_gem_load_paths'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:132:in `process'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/initializer.rb:113:in `run'    from /home/system/apps/app_name/trunk/config/environment.rb:9:in `<top (required)>'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:182:in `block in require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:547:in `new_constants_in'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/activesupport-2.3.11/lib/active_support/dependencIEs.rb:182:in `require'    from /home/system/.rvm/gems/ruby-1.9.2-p320@gemset_name/gems/rails-2.3.11/lib/commands/server.rb:84:in `<top (required)>'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'    from /home/system/.rvm/rubIEs/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require'    from script/server:3:in `<main>'

以下是我的environment.rb: –

# Be sure to restart your server when you modify this file# SpecifIEs gem version of Rails to use when vendor/rails is not presentRAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION# bootstrap the Rails environment,frameworks,and default configurationrequire file.join(file.dirname(__file__),'boot')Rails::Initializer.run do |config|  config.gem 'jrails'  # Settings in config/environments/* take precedence over those specifIEd here.  # Application configuration should go into files in config/initializers  # -- all .rb files in that directory are automatically loaded.  # Add additional load paths for your own custom dirs  # config.autoload_paths += %W( #{RAILS_ROOT}/extras )  # Specify gems that this application depends on and have them installed with rake gems:install  # config.gem "bj"  # config.gem "hpricot",:version => '0.6',:source => "http://code.whytheluckystiff.net"  # config.gem "sqlite3-ruby",:lib => "sqlite3"  # config.gem "aws-s3",:lib => "aws/s3"  # Only load the plugins named here,in the order given (default is Alphabetical).  # :all can be used as a placeholder for all plugins not explicitly named  # config.plugins = [ :exception_notification,:ssl_requirement,:all ]  # Skip frameworks you're not going to use. To use Rails without a database,# you must remove the Active Record framework.  # config.frameworks -= [ :active_record,:active_resource,:action_mailer ]  # Activate observers that should always be running  # config.active_record.observers = :cacher,:garbage_collector,:forum_observer  # Set Time.zone default to the specifIEd zone and make Active Record auto-convert to this zone.  # Run "rake -D time" for a List of tasks for finding time zone names.  config.time_zone = 'UTC'  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.  # config.i18n.load_path += Dir[Rails.root.join('my','locales','*.{rb,yml}')]  # config.i18n.default_locale = :deend

以下是我的rakefile: –

# Add your own tasks in files placed in lib/tasks ending in .rake,# for example lib/tasks/cAPIstrano.rake,and they will automatically be available to Rake.require(file.join(file.dirname(__file__),'config','boot'))require 'rake'require 'rake/testtask'require 'rdoc/task'require 'tasks/rails'

以下是我提到的解决方案的答案: –

Uninitialized constant ActiveSupport::Dependencies::Mutex (NameError)

undefined method `name’ for “actionmailer”:String

请帮我解决这个问题.
谢谢

解决方法 Ruby 1.9.2并不是那么新,你应该使用1.9.3-p448. Rubygems 1.8.25非常老,应该只与Ruby 1.8一起使用AFAIK.你可能正在使用一个非常古老的发行版.尝试使用 rvm安装最新的Ruby 1.9和Rubygems.这是一个简短的快速入门指南.遇到麻烦时请参考文档.

\curl -L https://get.rvm.io | bash -s stablervm install 1.9rvm use 1.9 --defaultrvm rubygems latest --verify-downloads 1gem install bundlerbundle exec ./script/server
总结

以上是内存溢出为你收集整理的ruby-on-rails – `add_frozen_gem_path’:Gem的未定义方法`source_index’:模块(NoMethodError)或不推荐使用Gem.source_index全部内容,希望文章能够帮你解决ruby-on-rails – `add_frozen_gem_path’:Gem的未定义方法`source_index’:模块(NoMethodError)或不推荐使用Gem.source_index所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1252639.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存