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
,它的工作原理。所以問題出在路徑上,但是有沒有辦法使用符號來避免使用source
和cd
?
一些想法:它可能與您的部署env權限有關嗎?或者capistrano發佈命令的文件夾?也許你用於命令名的符號(用逗號試試)。注意錯誤如何表示':'不是文件或文件夾。 – rlecaro2
你是什麼意思?就像我寫'execute:bundle','install''的地方一樣?如果是這樣,你會寫什麼,我不知道明白。 – Pacane
我的意思是'執行'bundle install''就好像你想要capistrano將文本粘貼爲命令一樣。 – rlecaro2