【问题标题】:capistrano fails to deploy Sprockets::FileNotFound submodule filecapistrano 无法部署 Sprockets::FileNotFound 子模块文件
【发布时间】:2014-06-30 04:48:26
【问题描述】:

我有一个安装了 capistrano 2 的 Rails 3.2 应用程序,并且我有许多子模块。我刚刚将 vendor/assets/javascripts/ui-utils 移到了一个子模块中。

[submodule "app/assets/javascripts/jquery.autotab"]
    path = app/assets/javascripts/jquery.autotab
    url = git@github.com:map7/jquery.autotab.git
[submodule "app/assets/javascripts/jquery.overdrive"]
    path = app/assets/javascripts/jquery.overdrive
    url = git@github.com:map7/jquery.overdrive.git
[submodule "app/assets/javascripts/jquery.validationEngine"]
    path = app/assets/javascripts/jquery.validationEngine
    url = https://github.com/posabsolute/jQuery-Validation-Engine.git
[submodule "app/assets/javascripts/keymaster"]
    path = app/assets/javascripts/keymaster
    url = git@github.com:map7/keymaster.git
[submodule "vendor/assets/javascripts/ui-utils"]
    path = vendor/assets/javascripts/ui-utils
    url = github.com:/map7/ui-utils.git

这只是我遇到问题的底部子模块。这可能是因为它在供应商/资产区域吗?

现在当我执行cap deploy 时,我收到以下错误

  * executing "cd -- /srv/pais/releases/20140630042430 && RAILS_ENV=production RAILS_GROUPS=assets env RBENV_ROOT=\"/usr/local/rbenv\" PATH=\"/usr/local/rbenv/shims:/usr/local/rbenv/bin:$PATH\" RBENV_VERSION=\"2.1.1\" /usr/local/rbenv/bin/rbenv exec bundle exec rake assets:precompile"
** [out :: staging.pais.com.au] rake aborted!
 ** [out :: staging.pais.com.au] Sprockets::FileNotFound: couldn't find file 'ui-utils/modules/keypress/keypress.js'
 ** [out :: staging.pais.com.au] (in /srv/pais/releases/20140630042430/app/assets/javascripts/application.js:42)
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:102:in `resolve'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:142:in `require_asset'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:215:in `process_require_directive'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:165:in `block in process_directives'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `each'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:163:in `process_directives'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/directive_processor.rb:97:in `evaluate'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
 ** [out :: staging.pais.com.au] /srv/pais/shared/bundle/ruby/2.1.0/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'

在我的开发机器上,这个文件确实存在并且可以工作。

我尝试将以下内容放入我的 deploy.rb 中,但没有成功

set :git_enable_submodules, 1   # Get submodules
set :git_submodules_recursive, true
namespace :git do
  desc "Init & update submodules"
  task :update_submodules, :roles => :app do
    run("cd #{release_path} && git submodule init && git submodule update")
  end
end
before "deploy:assets:precompile", "git:update_submodules"

2014 年 6 月 30 日更新

注意到,如果我转到任何其他子模块并输入git status,那么我会得到以下信息;

# On branch master
# Your branch is up-to-date with 'origin/master'.
#
nothing to commit, working directory clean

如果我转到我的 ui-utils 子模块并输入 git status 我得到

# HEAD detached at 4e86ac7
nothing to commit, working directory clean

如果我运行以下命令,我正在运行 git 版本 1.9.1

git submodule deinit -f vendor/assets/javascripts/ui-utils

然后尝试使用再次添加它

git submodule add git@github.com:map7/ui-utils.git vendor/assets/javascripts/ui-utils

我收到以下错误

A git directory for 'vendor/assets/javascripts/ui-utils' is found locally with remote(s):
  origin    https://github.com/map7/ui-utils.git
If you want to reuse this local git directory instead of cloning again from
  git@github.com:map7/ui-utils.git
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.

更新

我设法通过以下操作从 git 中完全删除了 vendor/assets/javascripts/ui-utils How do I remove a submodule?

我现在通过子模块再次添加它,现在它就像其他子模块一样,但我仍然遇到部署问题。

更新

如果我使用cap --debug deploy 并在出现错误之前停止它,然后我 ssh 到我的服务器并执行 git status 我可以看到服务器上的子模块和 capistrano 存在一些问题;

git status
# On branch deploy
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#   deleted:    log/searchd.test.pid
#   modified:   vendor/assets/javascripts/ui-utils (modified content)
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   REVISION
#   app/assets/javascripts/jquery.autotab/
#   log
no changes added to commit (use "git add" and/or "git commit -a")

【问题讨论】:

    标签: ruby-on-rails git capistrano git-submodules


    【解决方案1】:

    我找到了解决方案,可能会将其保留在这里。这是多件事

    1. 我必须完全删除我的子模块并重新正确添加它
    2. 必须从我的 deploy.rb 文件中删除 set :deploy_via, :remote_cache

    cap --debug deploy 在这里帮了很多忙。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多