开发者

Rails 3 Devise or Authlogic - Production Env Mysteriously Can't See Gem? Works on Dev

This problem is probably very easy to solve but somehow I cannot find a solution.

This happens for BOTH Authlogic and Devise. I have been banging my head against the wall so long that I actually ripped out Authlogic and restarted with Devise -- but experience same problem.

On dev everything is fine.

However, when I get to production, I get this whenever I try to rake db:seed or run the console. This also shows me restarting the server and my gemfile.

Why can't production see the gem? It seems to be able to see the other gems just fine.

The gem you see is the Github version -- this was a recommended fix that does not work for me. I get the same result with the default version, and with forcing a specific version.

The fact that both Authlogic and Devise have the same problem seems to indicate there is some problem with my config on production? What could it be other than the Gemfile?

Dev - Rails 3.0.4, 1.9.2p136 Prod - Rails 3.0.4, 1.9.2p0

Last resort would be upgrading Ruby so they match, but I doubt this is the problem and it would be a lot of work for some reasons 开发者_JS百科I won't go into here.

ops@lightserve2:/home/proj/current$ touch tmp/restart.txt 

ops@lightserve2:/home/proj/current$ r c
/home/darkserve/releases/20110217175218/config/initializers/devise.rb:3:in `<top (required)>': uninitialized constant Devise (NameError)
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `each'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/engine.rb:200:in `block in <class:Engine>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `instance_exec'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:25:in `run'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:50:in `block in run_initializers'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `each'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/initializable.rb:49:in `run_initializers'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:134:in `initialize!'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:77:in `method_missing'
    from /home/darkserve/releases/20110217175218/config/environment.rb:5:in `<top (required)>'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/application.rb:103:in `require_environment!'
    from /home/ops/shared/bundle/ruby/1.9.1/gems/railties-3.0.4/lib/rails/commands.rb:22:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'



ops@lightserve2:/home/darkserve/current$ cat Gemfile.lock 
GIT
  remote: http://github.com/JonasNielsen/nifty-generators.git
  revision: 432d05d55b55e030d6c16b9d71b392181bca45f8
  specs:
    nifty-generators (0.4.3)

GIT
  remote: http://github.com/plataformatec/devise.git
  revision: 7113beac81a12da06be2d08bbfaec79017e9fdbf
  specs:
    devise (1.2.rc)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)

GEM
  remote: http://rubygems.org/
  specs:
    aaronh-chronic (0.3.9)
    abstract (1.0.0)
    actionmailer (3.0.4)
      actionpack (= 3.0.4)
      mail (~> 2.2.15)
    actionpack (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.4)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.13)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.4)
      activesupport (= 3.0.4)
      builder (~> 2.1.2)
      i18n (~> 0.4)
    activerecord (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
      arel (~> 2.0.2)
      tzinfo (~> 0.3.23)
    activeresource (3.0.4)
      activemodel (= 3.0.4)
      activesupport (= 3.0.4)
    activesupport (3.0.4)
    arel (2.0.8)
    bcrypt-ruby (2.1.4)
    builder (2.1.2)
    capistrano (2.5.19)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.0.0)
    crack (0.1.8)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    foreigner (0.9.1)
    haml (3.0.25)
    haml-rails (0.3.4)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      haml (~> 3.0)
      railties (~> 3.0)
    highline (1.6.1)
    hpricot (0.8.3)
    httparty (0.7.4)
      crack (= 0.1.8)
    i18n (0.5.0)
    json (1.5.1)
    mail (2.2.15)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mash (0.1.1)
    mime-types (1.16)
    mocha (0.9.12)
    mysql2 (0.2.6)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.1.0)
    net-ssh-gateway (1.0.1)
      net-ssh (>= 1.99.1)
    nokogiri (1.4.4)
    oauth (0.4.4)
    orm_adapter (0.0.4)
    polyglot (0.3.1)
    rack (1.2.1)
    rack-mount (0.6.13)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.4)
      actionmailer (= 3.0.4)
      actionpack (= 3.0.4)
      activerecord (= 3.0.4)
      activeresource (= 3.0.4)
      activesupport (= 3.0.4)
      bundler (~> 1.0)
      railties (= 3.0.4)
    railties (3.0.4)
      actionpack (= 3.0.4)
      activesupport (= 3.0.4)
      rake (>= 0.8.7)
      thor (~> 0.14.4)
    rake (0.8.7)
    ruby-freshbooks (0.4.0)
      builder (>= 2.1.2)
      httparty (>= 0.5.0)
    ruby_parser (2.0.5)
      sexp_processor (~> 3.0)
    sexp_processor (3.0.5)
    simple_form (1.3.1)
    thor (0.14.6)
    treetop (1.4.9)
      polyglot (>= 0.3.1)
    tzinfo (0.3.24)
    warden (1.0.3)
      rack (>= 1.0.0)
    whenever (0.6.2)
      aaronh-chronic (>= 0.3.9)
      activesupport (>= 2.3.4)
    yammer4r (0.1.5)
      json (>= 1.1.7)
      mash (>= 0.0.3)
      oauth (>= 0.3.5)

PLATFORMS
  ruby

DEPENDENCIES
  bcrypt-ruby
  capistrano
  devise!
  foreigner
  haml
  haml-rails
  hpricot
  mocha
  mysql2
  nifty-generators!
  nokogiri
  rails (= 3.0.4)
  ruby-freshbooks
  ruby_parser
  simple_form
  whenever
  yammer4r


Any chance that....

  1. You have not run bundle in the production environment (less likely)
  2. you have your gemfile divided into groups - you would see something like this

Gemfile

group :development do
     gem 'devise'
end


The problem turned out to be that there was another rails app installed on this slice, and rake/rails was trying to call the other app's rake/rails script when run due to a misconfiguration.

The problem was resolved in the short term by forcing the rails script in the /script directory of my app. E.g.

ruby script/rails console

instead of

rails console

However, I did not find a way to easily force my own copy of rake.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜