Capistrano 3.0资产:预编译在Rails上失败

金合欢

我尝试了几种使用Capistrano v3部署到我的服务器的方法,但是由于以下错误而失败。我尝试在本地进行预编译,但失败了。

DEBUG [4ec78ee3] Command: cd /var/www/html/webapp/releases/20140101221937 && bundle exec rake assets:precompile RAILS_ENV=production
DEBUG [4ec78ee3]    /usr/local/bin/ruby /var/www/html/webapp/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    undefined method `fetch' for false:FalseClass

我的部署文件如下所示;

SSHKit.config.command_map[:rake] = "bundle exec rake"

namespace :deploy do

  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

  after :finishing, 'deploy:cleanup'

end

这是详细的跟踪;

INFO [4ec78ee3] Running bundle exec rake assets:precompile RAILS_ENV=production on 208.68.39.56
DEBUG [4ec78ee3] Command: cd /var/www/html/webapp/releases/20140101221937 && bundle exec rake assets:precompile RAILS_ENV=production
DEBUG [4ec78ee3]    /usr/local/bin/ruby /var/www/html/webapp/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    undefined method `fetch' for false:FalseClass
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:35:in `resolve_string_connection'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `each'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
DEBUG [4ec78ee3]    /var/www/html/webapp/releases/20140101221937/config/environment.rb:5:in `<top (required)>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/railties-3.2.13/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
DEBUG [4ec78ee3]    Tasks: TOP => environment
DEBUG [4ec78ee3]    (See full trace by running task with --trace)
DEBUG [4ec78ee3]    rake aborted!
DEBUG [4ec78ee3]    Command failed with status (1): [/usr/local/bin/ruby /var/www/html/webapp/s...]
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:12:in `ruby_rake_task'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:21:in `invoke_or_reboot_rake_task'
DEBUG [4ec78ee3]    /var/www/html/webapp/shared/bundle/ruby/1.9.1/gems/actionpack-3.2.13/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
DEBUG [4ec78ee3]    Tasks: TOP => assets:precompile
DEBUG [4ec78ee3]    (See full trace by running task with --trace)

我跑了 cap production deploy:compile_assets

并得到了 帽流产了!

if test ! -d /var/www/html/webapp/current; then echo "Directory does not exist '/var/www/html/webapp/current'" 1>&2; false; fi stdout: Nothing written
if test ! -d /var/www/html/webapp/current; then echo "Directory does not exist '/var/www/html/webapp/current'" 1>&2; false; fi stderr: Nothing written

记住,它仍然是一个空文件。

戴维·格雷森

这不是一个完整的答案,而是故障排除的第一步。

首先,转到服务器并运行Capistrano运行的完全相同的命令,以确保可以重现完全相同的错误。这使Capistrano脱颖而出,现在该错误仅与Rails及其配置有关。

这是引发错误的行:

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb#L35

该错误消息告诉我们这configurations是错误的,但是代码期望它是某个响应的对象fetch(可能是哈希)。问题在于其中的@configurations实例变量ActiveRecord::Base::ConnectionSpecification::Resolverfalse错误地设置你知道为什么会这样吗?我将检查所有与数据库连接有关的配置文件,并确保它们看起来确定。

如果这样做没有帮助,则下一步是找出为什么将该变量设置为false好吧,如果我们在堆栈跟踪中低两行,我们可以看到如何创建和使用此Resolver对象:

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb#L129-130

该方法只是调用ActiveRecord::Base.configurations并将其传递给Resolver对象。因此,现在的问题变成了如何ActiveRecord::Base.configurations将其设置为false?

编辑1:

这是有关的文档和代码ActiveRecord::Base.configurations

https://github.com/rails/rails/blob/v3.2.13/activerecord/lib/active_record/base.rb#L341-369

听起来ActiveRecord::Base.configurations应该来自您的database.yml文件。您应该转到服务器,仔细查看您的database.yml文件,看看它是否可能被读为false。您应该在此处发布该文件。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Capistrano 3在资产上失败:预编译

来自分类Dev

Capistrano 部署资产失败:预编译

来自分类Dev

Rails 6 Capistrano错误“资产:预编译”

来自分类Dev

Capistrano 3进程失败

来自分类Dev

Capistrano 3 setfacl失败

来自分类Dev

预编译资产出现Rails 4 / Capistrano错误

来自分类Dev

/usr/bin/env ruby no such file or directory: Using capistrano 3, capistrano/rbenv, capistrano/bundler and capistrano/rails (using rails 4)

来自分类Dev

RVM,Capistrano 3和捆绑软件失败

来自分类Dev

RVM,Capistrano 3和捆绑软件失败

来自分类Dev

Rails,Capistrano 3和SSH代理转发

来自分类Dev

如何使用Capistrano 2部署Rails 4并在本地预编译资产

来自分类Dev

Rails Capistrano在本地预编译资产,但无法在生产中加载

来自分类Dev

/ usr / bin / env和Capistrano 3在Rails部署中失败

来自分类Dev

/ usr / bin / env和Capistrano 3在Rails部署中失败

来自分类Dev

Capistrano 3.1:Rake资产预编译无法正常工作

来自分类Dev

Capistrano V3在database.yml上失败

来自分类Dev

Capistrano V3在database.yml上失败

来自分类Dev

Capistrano:被杀死的RAILS_ENV =生产RAILS_GROUPS =资产捆绑执行佣金资产:预编译

来自分类Dev

Capistrano部署后,Rails资产未编译

来自分类Dev

/ usr / bin / env ruby没有这样的文件或目录:使用capistrano 3,capistrano / rbenv,capistrano / bundler和capistrano / rails(使用rails 4)

来自分类Dev

Capistrano 3 +链轮3 + Rails 4.2.1无法部署吗?

来自分类Dev

Capistrano资产:预编译部署失败并且日志不清楚,其他人可以看看吗?

来自分类Dev

ssh_options在capistrano3中解析失败

来自分类Dev

Capistrano 3部署是否与Rails 4容器冲突?

来自分类Dev

Capistrano 3是否仍将Rails日志置于共享/日志中

来自分类Dev

部署Rails项目时,Capistrano 3不会创建“当前”目录

来自分类Dev

Ruby on Rails以及+ capistrano v3集成

来自分类Dev

部署时,Capistrano 3未运行Rails迁移

来自分类Dev

Ruby on Rails以及+ capistrano v3集成

Related 相关文章

  1. 1

    Capistrano 3在资产上失败:预编译

  2. 2

    Capistrano 部署资产失败:预编译

  3. 3

    Rails 6 Capistrano错误“资产:预编译”

  4. 4

    Capistrano 3进程失败

  5. 5

    Capistrano 3 setfacl失败

  6. 6

    预编译资产出现Rails 4 / Capistrano错误

  7. 7

    /usr/bin/env ruby no such file or directory: Using capistrano 3, capistrano/rbenv, capistrano/bundler and capistrano/rails (using rails 4)

  8. 8

    RVM,Capistrano 3和捆绑软件失败

  9. 9

    RVM,Capistrano 3和捆绑软件失败

  10. 10

    Rails,Capistrano 3和SSH代理转发

  11. 11

    如何使用Capistrano 2部署Rails 4并在本地预编译资产

  12. 12

    Rails Capistrano在本地预编译资产,但无法在生产中加载

  13. 13

    / usr / bin / env和Capistrano 3在Rails部署中失败

  14. 14

    / usr / bin / env和Capistrano 3在Rails部署中失败

  15. 15

    Capistrano 3.1:Rake资产预编译无法正常工作

  16. 16

    Capistrano V3在database.yml上失败

  17. 17

    Capistrano V3在database.yml上失败

  18. 18

    Capistrano:被杀死的RAILS_ENV =生产RAILS_GROUPS =资产捆绑执行佣金资产:预编译

  19. 19

    Capistrano部署后,Rails资产未编译

  20. 20

    / usr / bin / env ruby没有这样的文件或目录:使用capistrano 3,capistrano / rbenv,capistrano / bundler和capistrano / rails(使用rails 4)

  21. 21

    Capistrano 3 +链轮3 + Rails 4.2.1无法部署吗?

  22. 22

    Capistrano资产:预编译部署失败并且日志不清楚,其他人可以看看吗?

  23. 23

    ssh_options在capistrano3中解析失败

  24. 24

    Capistrano 3部署是否与Rails 4容器冲突?

  25. 25

    Capistrano 3是否仍将Rails日志置于共享/日志中

  26. 26

    部署Rails项目时,Capistrano 3不会创建“当前”目录

  27. 27

    Ruby on Rails以及+ capistrano v3集成

  28. 28

    部署时,Capistrano 3未运行Rails迁移

  29. 29

    Ruby on Rails以及+ capistrano v3集成

热门标签

归档