我现在正尝试在Nginx上安装Rails 4.2。每次我用RVM启动一个新的安装时,它都会变得很好。我可以运行rake db:create:all并创建数据库。但是,如果我使用/etc/init.d/nginx restart重新启动Nginx,乘客会向我发送一个关于gem的错误:
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
bundle install
If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:
    Is this app supposed to be run as the www-data user?
    Is this app being run on the correct Ruby interpreter? Below you will see which Ruby interpreter Phusion Passenger attempted to use.
-------- The exception is as follows: -------
Could not find pg-0.18.3 in any of the sources (Bundler::GemNotFound)
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:92:in `block in materialize'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `map!'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/spec_set.rb:85:in `materialize'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:140:in `specs'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:185:in `specs_for'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/definition.rb:174:in `requested_specs'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/environment.rb:18:in `requested_specs'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/runtime.rb:13:in `setup'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler.rb:127:in `setup'
  /var/lib/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/setup.rb:18:in `<top (required)>'
  /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:411:in `activate_gem'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:295:in `block in run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:416:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:294:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:99:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:153:in `<module:App>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:28:in `<main>'gem已经安装在我的Gemfile和RVM中:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
gem 'pg', '~> 0.18.3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'execjs'
group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'
end
group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end如果我运行gem query --local,就会得到pg (0.18.3)
config/database.yml:
login: &login
  adapter: postgresql
  username: myuser
  password: mypass
  host: localhost
  encoding: UTF8
development:
  <<: *login
  database: mydb_dev
test:
  <<: *login
  database: mydb_test
production:
  <<: *login
  database: mydb_prodrvm信息:
  ruby:
    interpreter:  "ruby"
    version:      "2.2.1p85"
    date:         "2015-02-26"
    platform:     "x86_64-linux"
    patchlevel:   "2015-02-26 revision 49769"
    full_version: "ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]"
  homes:
    gem:          "/usr/local/rvm/gems/ruby-2.2.1"
    ruby:         "/usr/local/rvm/rubies/ruby-2.2.1"
  binaries:
    ruby:         "/usr/local/rvm/rubies/ruby-2.2.1/bin/ruby"
    irb:          "/usr/local/rvm/rubies/ruby-2.2.1/bin/irb"
    gem:          "/usr/local/rvm/rubies/ruby-2.2.1/bin/gem"
    rake:         "/usr/local/rvm/rubies/ruby-2.2.1/bin/rake"
  environment:
    PATH:         "/usr/local/rvm/gems/ruby-2.2.1/bin:/usr/local/rvm/gems/ruby-2.2.1@global/bin:/usr/local/rvm/rubies/ruby-2.2.1/bin:/usr/local/rvm/bin:/root/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    GEM_HOME:     "/usr/local/rvm/gems/ruby-2.2.1"
    GEM_PATH:     "/usr/local/rvm/gems/ruby-2.2.1:/usr/local/rvm/gems/ruby-2.2.1@global"
    MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-2.2.1"
    IRBRC:        "/usr/local/rvm/rubies/ruby-2.2.1/.irbrc"
    RUBYOPT:      ""当我试图重新启动Nginx时,我是不是做错了什么?
发布于 2015-10-05 18:35:38
您似乎已经安装了gem,但是当您重新启动时,您的绑定器并没有找到它。
以下是一些想法:
bundle exec gem list来查看包中的实际内容,而不仅仅是本地安装的内容(这就是您在gem query --local中看到的)。https://stackoverflow.com/questions/32954946
复制相似问题