2014-01-22 41 views
0

我无法让Capistrano运行捆绑命令和耙子命令。 我得到的调试日志是这样的:无法让Capistrano调用捆绑和耙子命令

DEBUG [0f557e7e] /usr/bin/env: bundle 
DEBUG [0f557e7e] : No such file or directory 

我RVM上的所有计算机马(开发和生产)

这里是我的配置:

deploy.rb

lock '3.1.0' 

set :application, 'blog' 
set :repo_url, '[email protected]:xxx/yyyy.git' 

set :deploy_to, '/home/joel/apps/blog' 

set :deploy_via, :copy 


set :rvm_ruby_version, '2.1.0p0' 
set :default_env, { rvm_bin_path: '/home/joel/.rvm/bin:$PATH' } 

SSHKit.config.command_map[:rake] = "#{fetch(:default_env)[:rvm_bin_path]}/rvm ruby-#{fetch(:rvm_ruby_version)} do 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 

    desc 'Migrate db' 
    task :migrate do 
    on primary :db do 
     within release_path do 
      execute :rake, 'db:migrate' 
     end 
    end 
    end 

    desc 'Bundle install' 
    task :bundle do 
    on primary :app do 
     within release_path do 
      execute :bundle, 'install' 
     end 
    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 

end 

生产.rb

role :app, %w{[email protected]} 
role :web, %w{[email protected]} 
role :db, %w{[email protected]} 
server 'yyy.com', user: 'xxx', roles: %w{web app}, my_property: :my_value 

capfile

require 'capistrano/setup' 

require 'capistrano/deploy' 

require 'capistrano/rvm' 
require 'capistrano/bundler' 
require 'capistrano/rails/assets' 
require 'capistrano/rails/migrations' 


Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } 

,当我尝试调用

cap production deploy:bundle 

如果我要打电话bundle:install在生产服务器上,这是我得到:

INFO [0f557e7e] Running /usr/bin/env bundle install on yyy.com 
DEBUG [0f557e7e] Command: cd /home/joel/apps/blog/current && (RVM_BIN_PATH=/home/joel/.rvm/bin:$PATH /usr/bin/env bundle install) 
DEBUG [0f557e7e] /usr/bin/env: bundle 
DEBUG [0f557e7e] : No such file or directory 

尽管如此,如果我SSH到服务器上并复制粘贴该命令,它工作正常。 (同样的事情发生在采取命令,如rake db:migrate)。我敢肯定它是与路径,所以这里是我的

rvm info

ruby-2.1.0: 

    system: 
    uname:  "Linux li101-172 3.12.6-x86_64-linode36 #2 SMP Mon Jan 13 18:54:10 EST 2014 x86_64 x86_64 x86_64 GNU/Linux" 
    system:  "ubuntu/12.04/x86_64" 
    bash:  "/bin/bash => GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu)" 
    zsh:   "/usr/bin/zsh => zsh 4.3.17 (x86_64-unknown-linux-gnu)" 

    rvm: 
    version:  "rvm 1.25.14 (stable) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]" 
    updated:  "15 days 19 hours 42 minutes 40 seconds ago" 
    path:   "/home/joel/.rvm" 

    ruby: 
    interpreter: "ruby" 
    version:  "2.1.0p0" 
    date:   "2013-12-25" 
    platform:  "x86_64-linux" 
    patchlevel: "2013-12-25 revision 44422" 
    full_version: "ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]" 

    homes: 
    gem:   "/home/joel/.rvm/gems/ruby-2.1.0" 
    ruby:   "/home/joel/.rvm/rubies/ruby-2.1.0" 

    binaries: 
    ruby:   "/home/joel/.rvm/rubies/ruby-2.1.0/bin/ruby" 
    irb:   "/home/joel/.rvm/rubies/ruby-2.1.0/bin/irb" 
    gem:   "/home/joel/.rvm/rubies/ruby-2.1.0/bin/gem" 
    rake:   "/home/joel/.rvm/rubies/ruby-2.1.0/bin/rake" 

    environment: 
    PATH:   "/home/joel/.rvm/gems/ruby-2.1.0/bin:/home/joel/.rvm/gems/[email protected]/bin:/home/joel/.rvm/rubies/ruby-2.1.0/bin:/home/joel/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" 
    GEM_HOME:  "/home/joel/.rvm/gems/ruby-2.1.0" 
    GEM_PATH:  "/home/joel/.rvm/gems/ruby-2.1.0:/home/joel/.rvm/gems/[email protected]" 
    MY_RUBY_HOME: "/home/joel/.rvm/rubies/ruby-2.1.0" 
    IRBRC:  "/home/joel/.rvm/rubies/ruby-2.1.0/.irbrc" 
    RUBYOPT:  "" 
    gemset:  "" 

编辑:

我也试图消除所有的路径,并且在使用PermitUserEnvironment的〜/ .ssh /环境

和改变我的任务厕所

desc 'Bundle install' 
    task :bundle do 
    on primary :app do 
     within release_path do 
      execute 'source ~/.zshrc && cd ~/apps/blog/current/ && bundle install' 
      execute 'source ~/.zshrc && cd ~/apps/blog/current/ && RAILS_ENV=production rake db:migrate' 
      execute 'source ~/.zshrc && cd ~/apps/blog/current/ && RAILS_ENV=production rake assets:precompile' 
     end 
    end 
    end 

,它的工作原理。所以问题出在路径上,但是有没有办法使用符号来避免使用sourcecd

+0

一些想法:它可能与您的部署env权限有关吗?或者capistrano发布命令的文件夹?也许你用于命令名的符号(用逗号试试)。注意错误如何表示':'不是文件或文件夹。 – rlecaro2

+0

你是什么意思?就像我写'execute:bundle','install''的地方一样?如果是这样,你会写什么,我不知道明白。 – Pacane

+0

我的意思是'执行'bundle install''就好像你想要capistrano将文本粘贴为命令一样。 – rlecaro2

回答

0

我最终重新安装了RVM,并解决了我的路径问题。我仍然不知道它为什么会起作用,但它起作用。