我在生产中遇到了一个在开发过程中没有出现的错误。在堆栈跟踪中,gem使用了错误版本的ruby(2.1.0),但我在我的gemfile中指定了2.1.3并在ruby版本上执行了heroku故障排除。基于其他stackoverflow信息,ruby版本在这里有所不同。任何人都知道如何将app / vendor / bundle更新到最新版本?
这是我在Resque工作人员中发生的错误......
undefined method `name' for nil:NilClass
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:72:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:74:in `block in initialize'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:150:in `yield'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:150:in `accept'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych/visitors/yaml_tree.rb:114:in `push'
/app/vendor/bundle/ruby/2.1.0/gems/psych-2.0.6/lib/psych.rb:409:in `dump'
...snip...
这是我的红宝石版......
heroku run "ruby --version"
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux]
这是/ app / vendor / bundle中的内容......
heroku run "ls /app/vendor/bundle/ruby"
2.1.0
这是我的Gemfile ruby声明......
source 'https://rubygems.org'
group :default do
# current stable (heroku needs this listed)
ruby '2.1.3'
gem 'rails', '4.1.1'
gem 'redis' # queue mechanism
gem 'resque', "~> 1.22.0", :require => "resque/server"
gem 'resque_mailer' # mailer queue
gem 'resque-scheduler' # job scheduler
# postgres and database
gem 'pg' # postgres
gem 'activerecord-import' # bulk sql insert
gem 'seed-fu', '~> 2.3' # db seed data
# APIs
gem 'bitly'
gem 'feedjira' # RSS feeds
gem 'fullcontact'
gem 'httparty'# rest api client
gem 'twilio-ruby' # SMS
gem 'twitter'
gem 'twitter-text' # convert twitter, links, hashtags and users
gem 'yahoo-finance', require: 'yahoo_finance'
# WEB....
# Use unicorn as the app server
gem 'unicorn'
# javascript
gem 'jquery-rails'
gem 'uglifier', '>= 1.3.0' # compressor for js assets
gem 'coffee-rails', '~> 4.0.0'
# UI/CSS
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass'
gem 'jquery-ui-rails'
gem 'jqcloud-rails' # word cloud
gem 'footable-rails' # mobile responsive table
gem 'font-awesome-sass'# icons
gem 'highcharts-rails'
# rails
gem 'turbolinks'
gem 'simple_form'
# admin interface
gem 'rails_admin' # models admin interface
gem "psych", "~> 2.0.5" # needed for rails_admin
# user authentication
gem 'devise'
gem 'domp'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-stocktwits', :git => 'https://github.com/jesseyoungmann/omniauth-stocktwits.git'
# app support
gem 'bcrypt', '~> 3.1.2' # for active model secure password
gem 'kaminari', :git => 'https://github.com/musicglue/kaminari.git' # pagination
end
# docs
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# test
group :test do
gem "capybara"
gem 'factory_girl_rails'
gem 'faker'
gem 'rspec-rails'
gem 'selenium-webdriver'
gem 'simplecov', :require => false
gem 'vcr', '~> 2.8.0'
gem 'webmock', '~> 1.15.0'
end
# development
group :development do
gem 'foreigner', '~> 1.6.1' # foreign key generator
gem 'rails_layout'
# profilers
gem 'rack-mini-profiler'
gem 'ruby-prof'
end
group :production do
gem 'newrelic_rpm'
gem 'rails_12factor' # heroku
end
谢谢!
答案 0 :(得分:0)
一种可能的解决方案是在应用程序的根目录中创建一个.ruby-version
文件,只需将2.1.3
放入其中,而您的应用程序将始终在生产和开发中使用该版本。我过去也遇到过类似的问题,这对我来说很有用。
答案 1 :(得分:0)