Ruby on rails 3 Capistrano 3.1:rake资产预编译不工作

Ruby on rails 3 Capistrano 3.1:rake资产预编译不工作,ruby-on-rails-3,capistrano,Ruby On Rails 3,Capistrano,我是Capistrano的新手,正在尝试预编译这些资产。输入命令cap production deploy后,我的代码已成功部署到服务器上,但未编译我的资产。下面是我的deploy.rb文件 #SSHKit.config.command_map[:rake] = "bundle exec rake" # config valid only for Capistrano 3.1 lock '3.1.0' set :application, 'woi' set :repo_url,

我是Capistrano的新手,正在尝试预编译这些资产。输入命令
cap production deploy
后,我的代码已成功部署到服务器上,但未编译我的资产。下面是我的deploy.rb文件

       #SSHKit.config.command_map[:rake] = "bundle exec rake"
# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'woi'
set :repo_url, 'git@github.com:sanjay-salunkhe/cap.git'
set :branch, "master"
set :deploy_via, :remote_cache
set :stages, ["production"]

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

# Default deploy_to directory is /var/www/my_app
 set :deploy_to, '/home/webuser/apps/cap/'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
# set :linked_files, %w{config/database.yml}

# Default value for linked_dirs is []
# set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
# set :default_env, { path: "/opt/ruby/bin:$PATH" }

# Default value for keep_releases is 5
 set :keep_releases, 5

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 :publishing, :restart

  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


  desc 'precompiling assets..............'
  task :composer_install do
    on roles(:web) do
      within release_path do
        execute :rake, "assets:precompile RAILS_ENV=production"
      end
    end
  end

  after :publishing, 'deploy:composer_install'



end
下面是我的日志

   DEBUG [cf204b99]     /usr/bin/env: 
DEBUG [cf204b99]    rake
DEBUG [cf204b99]    : No such file or directory
DEBUG [cf204b99]    
cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
/var/lib/gems/1.9.1/gems/sshkit-1.3.0/lib/sshkit/backends/netssh.rb:142:in `block (4 levels) in _exe
如果可能,请将Capistrano 3.1的良好文档链接发送给我


谢谢,

您需要在一个命令中更改目录并编译资源。 我正在使用这个:
execute“cd#{release_path}/&&RAILS_ENV=production bundle exec rake assets:precompile”

有时(取决于服务器配置),capistrano可能会引发一个错误,即它找不到“bundle”,然后您必须使用以下命令找到bundle在服务器上的位置:
哪个bundle

并将完整路径添加到上述行,在我的配置中,需要提供完整路径:

execute“cd#{release_path}/&&RAILS_ENV=production/usr/local/bin/bundle exec rake assets:precompile”

最后,我设法使用capastrano 3部署我的应用程序。实际上,我的capfile中没有包含以下两行内容

 require 'capistrano/rvm'
require 'capistrano/rails'

包括这两行之后,我的问题就解决了。

对于Rails 4和Capistrano 3,我发现没有必要编写Capistrano配方来预编译用于生产的资产

相反,在我之前

cap生产部署

我只是跑

rake资产:预编译RAILS\u ENV=production


从我的本地机器开始,然后继续部署。

我必须更新节点并在服务器上安装Thread,以使rake资产:预编译工作。
令人沮丧的是,它没有产生任何错误或反馈。我只是在做rake资产时才发现这个问题:clobber

请提供日志。部署时它是否在日志中显示
rake资产:预编译
?否它不在revision.log文件中的任何位置显示rake资产:预编译。我在问题中添加了revision.log文件内容。否我指的是部署时打印在控制台上的日志。否,它没有在日志中的任何位置显示rake资产:预编译。检查更新的日志在问题中。@UandI-我已经更新了我的deploye.rb文件,现在我得到的错误是DEBUG[cf204b99]/usr/bin/env:DEBUG[cf204b99]rake DEBUG[cf204b99]:没有这样的文件或目录DEBUG[cf204b99]cap被中止。请查看我更新的问题。还记得将这些添加到您的文件中。gem“capistrano rvm”和gem“capistrano-rails”有什么帮助?它是否与生产服务器同步?