简体   繁体   English

Capistrano,Rails“宝石没装。 将`gem'sqlite3'添加到您的Gemfile中“

[英]Capistrano, Rails “gem is not loaded. Add `gem 'sqlite3'` to your Gemfile”

To start off, I am a beginner when it comes to Rails and Capistrano. 首先,我是Rails和Capistrano的初学者。 My development environment works without any issues and I wanted to push first as a test environment on a local virtual machine with the same setup as my production server. 我的开发环境没有任何问题,我想首先作为测试环境在本地虚拟机上推送,其设置与我的生产服务器相同。

I chose Capistrano to handle the deployment and setup everything according to the tutorial of the official website. 我选择Capistrano来处理部署并根据官方网站的教程设置所有内容。

The specs are: 规格是:

  • ubuntu Ubuntu的
  • ruby-2.0.0-p247 红宝石2.0.0-P247
  • rails 4.1.0.beta1 rails 4.1.0.beta1
  • capistrano 3 卡皮斯特拉诺3
  • phusion passenger 乘客

My Gemfile: 我的Gemfile:

gem 'rails', '4.1.0.beta1'
gem 'rails-i18n', '~> 4.0.0'

group :assets do
  # Use SCSS for stylesheets
  gem 'sass-rails', '4.0.2'

  gem 'uglifier', '>= 1.3.0'
end

gem 'bourbon'
gem 'foundation-rails'

group :development do

  gem 'capistrano', '~> 3.0.1'
  gem 'net-ssh', '~> 2.7.0'
  gem 'capistrano-rails', '~> 1.1.0'
  gem 'capistrano-bundler'
  gem 'capistrano-rvm'
  gem 'capistrano-rbenv', "~> 2.0"
end

group :development, :test do
  gem 'sqlite3'
  gem 'rspec-rails'
end

group :test, :production do
#  gem 'mysql2'
end

gem 'jquery-rails'

My deploy.rb file: 我的deploy.rb文件:

set :application, 'appliname'
set :deploy_user, 'deploy'
set :use_sudo,    false
set :repo_url, 'git@server:path/to/project.git'
set :branch, "master"

set :scm, :git

# set :format, :pretty
# set :log_level, :debug
set :pty, true

# setup rvm.
set :rbenv_type, :system
set :rbenv_ruby, 'ruby-2.0.0-p247'
set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec"
set :rbenv_map_bins, %w{rake gem bundle ruby rails}

# files we want symlinking to specific entries in shared.
set :linked_files, %w{config/database.yml config/private_env.yml}

# dirs we want symlinking to shared
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# set :default_env, { path: "/opt/ruby/bin:$PATH" }
set :keep_releases, 5

namespace :deploy do

  # make sure we're deploying what we think we're deploying
  # only allow a deploy with passing tests to deployed
  # before :deploy, "deploy:run_tests"

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      # Your restart mechanism here, for example:
      execute :touch, release_path.join('tmp/restart.txt')
    end
  end

  after :restart, :clear_cache do
    on roles(:web), in: :groups, limit: 3, wait: 10 do
      # Here we can do anything such as:
       within release_path do
         execute :rake, 'cache:clear'
       end
    end
  end

  # compile assets locally then rsync
  # after 'deploy:symlink:shared', 'deploy:compile_assets'
  # after :finishing, 'deploy:cleanup'

end

deploy/test.rb 部署/ test.rb

set :stage, :test

server 'testserver.local', user: fetch(:deploy_user), roles: %w{web app db}
set :deploy_to, '/home/project/public'
set :enable_ssl, false

My database.yml At first I wanted to use MySql even for my test environment, but for the deployment debugging sake, I temporary put sqlite. 我的database.yml起初我甚至想在我的测试环境中使用MySql,但是为了部署调试,我暂时放了sqlite。

default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

test: &test
  <<: *default
  database: db/test.sqlite3
#  adapter: mysql2
#  encoding: utf8
#  reconnect: true
#  database: ENV['database']
#  pool: 5
#  username: ENV['username']
#  password: ENV['password']
#  host: localhost

production:
  <<: *test

And finally the error message after running the following deply command: 最后运行以下deply命令后出现错误消息:

cap test deploy

Error: 错误:

DEBUG [f012bc9e] Command: cd /home/project/public/releases/20140319125218 && ( RAILS_ENV=test bundle exec rake assets:precompile )
DEBUG [f012bc9e]    rake aborted!
DEBUG [f012bc9e]
DEBUG [f012bc9e]    Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:58:in `rescue in resolve_hash_connection'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:55:in `resolve_hash_connection'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:46:in `resolve_string_connection'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/connection_adapters/connection_specification.rb:30:in `spec'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/connection_handling.rb:39:in `establish_connection'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/railtie.rb:126:in `block (2 levels) in <class:Railtie>'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:27:in `each'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activerecord-4.1.0.beta1/lib/active_record/railtie.rb:124:in `block in <class:Railtie>'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:30:in `instance_exec'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:30:in `run'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/
DEBUG [f012bc9e]    ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:55:in `block in run_initializers'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/initializable.rb:54:in `run_initializers'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:285:in `initialize!'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/releases/20140319125218/config/environment.rb:8:in `<top (required)>'
DEBUG [f012bc9e]
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/dependencies.rb:247:in `require'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/dependencies.rb:247:in `block in require'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/dependencies.rb:232:in `load_dependency'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/activesupport-4.1.0.beta1/lib/active_support/dependencies.rb:247:in `require'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:261:in `require_environment!'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/railties-4.1.0.beta1/lib/rails/application.rb:344:in `block in run_tasks_blocks'
DEBUG [f012bc9e]    /home/project/public/shared/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
DEBUG [f012bc9e]    Tasks: TOP => environment
DEBUG [f012bc9e]
DEBUG [f012bc9e]    (See full trace by running task with --trace)
DEBUG [f012bc9e]
cap aborted!
rake stdout: Nothing written
rake stderr: Nothing written
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _execute'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `call'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:551:in `do_request'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:561:in `channel_request'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:269:in `wait'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:164:in `block (2 levels) in _execute'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `call'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:221:in `preprocess'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:205:in `process'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `block in loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/net-ssh-2.8.0/lib/net/ssh/connection/session.rb:169:in `loop'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:166:in `block in _execute'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `tap'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:123:in `_execute'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:59:in `block (6 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:89:in `with'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:58:in `block (5 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/abstract.rb:81:in `within'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/capistrano-rails-1.1.1/lib/capistrano/tasks/assets.rake:57:in `block (4 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/username/.rvm/gems/ruby-2.0.0-p247/gems/sshkit-1.3.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written

So basically, with either the MySql2 gem or sqlite gem, I have the same kind of error... I am completely lost and have been looking over the web and did multiple tests with no avail. 所以基本上,无论是MySql2 gem还是sqlite gem,我都有同样的错误......我完全迷失了,并且一直在网上查看并做了多次测试但没有用。

Obviously I have run on the dev computer 'bundle update' and 'bundle install' when necessary. 显然,我已经在dev计算机上运行了“bundle update”和必要时的“bundle install”。 But I suppose that all these commands are run automatically by Capistrano on deployment. 但我想所有这些命令都是由Capistrano在部署时自动运行的。

So if a good soul could help with this it would make me very happy and I might stop losing my hair (or not) :) 因此,如果一个好的灵魂可以帮助这个,它会让我很高兴,我可能会停止失去我的头发(或不):)

If more info is needed, please ask! 如果需要更多信息,请询问! Thank you 谢谢

Your sqlite3 gem is not being loaded in production, because of where you've got it in the Gemfile. 你的sqlite3 gem没有在生产中加载,因为你在Gemfile中得到它。 Take it out of any groups, or move it to the group :test, :production group. 将其从任何组中取出,或将其移至group :test, :production group。

Your sqlite3 gem is not being loaded in production, because of the version mismatch. 由于版本不匹配,您的sqlite3 gem未在生产中加载。 so, update you gemfile as gem 'sqlite3', '~> 1.3.13' it'll work. 所以,将gemfile更新为gem'sqlite3 gem 'sqlite3', '~> 1.3.13'它会起作用。 Keep it under group :production, :test It'll be good when you push your code to heroku. 将它保存在group :production, :test当你将代码推送到heroku时会很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails - “将&#39;gem sqlite3&#39;&#39; 添加到您的 Gemfile” - Ruby on Rails - "Add 'gem sqlite3'' to your Gemfile" Ruby on Rails错误:数据库适配器指定为“ mysql2”,但未加载gem。 将`gem&#39;mysql2&#39;`添加到您的Gemfile - Ruby on Rails error: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile 为数据库适配器指定了“ mysql”,但未加载gem。 将`gem&#39;mysql&#39;`添加到您的Gemfile - Specified 'mysql' for database adapter, but the gem is not loaded. Add `gem 'mysql'` to your Gemfile Gem::LoadError: sqlite3 不是捆绑包的一部分。 将它添加到您的 Gemfile - Gem::LoadError: sqlite3 is not part of the bundle. Add it to your Gemfile 如何将 Sqlite3 gem 添加到 Gemfile? - How to add Sqlite3 gem to the Gemfile? 如何在 Mac 上使用 Sqlite3 运行 rails? 我收到“ gem 未加载”,但它已包含在 Gemfile 中 - How can I run rails with Sqlite3 on Mac? I'm getting " gem is not loaded" but it was included on Gemfile 加载“sqlite3”Active Record 适配器时出错。 缺少它所依赖的宝石? sqlite3 不是捆绑包的一部分。 将它添加到您的 Gemfile 中以获得 heroku - Error loading the 'sqlite3' Active Record adapter. Missing a gem it depends on? sqlite3 is not part of the bundle. Add it to your Gemfile for heroku 将Gem&#39;wdm&#39;添加到您的GemFile - Add Gem 'wdm' to your GemFile Capistrano 将我的应用程序从 Sqlite3 更新到 Rails,Gem::LoadError - Capistrano updating my app from Sqlite3 to Rails, Gem::LoadError Gem :: LoadError:将`gem'mysql'添加到你的Gemfile中 - Gem::LoadError: Add `gem 'mysql'` to your Gemfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM