我試圖將我們的capistrano2腳本升級到最新的capistrano,但是努力讓它工作。爲了限制轉換的任何問題,我開始了一個空的項目,並做了cap install
。Capistrano 3.8.1從窗口部署
添加了一個自定義任務以在本機上運行並試用它。同樣的結果。
這是我發現了錯誤:Errno::ENOENT: No such file or directory - /usr/bin/env dir
精確操作的指令:
1)MKDIR capdemo
2)CD capdemo
3)蓋安裝
4 )使用以下內容在lib/capistrano/tasks/foo.rake下創建文件:
namespace :foo do desc "Foo" task :local do run_locally do execute :dir end end end
5)運行cap staging foo:local
我在Windows 10,紅寶石2.2.4和斯特拉努與Capistrano的執行與/usr/bin/env
默認前綴3.8.1
```[email protected] MINGW64 ~/inpay_git/capdemo
$ cap staging foo:local -p --trace
** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke foo:local (first_time)
** Execute foo:local
Config variable set: :print_config_variables => true
Config variable set: :stage => :staging
Config variable set: :scm => :"default-git"
Config variable set: :branch => "master"
Config variable set: :deploy_to => #<Proc:[email protected]:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/defaults.rb:25 (lambda)>
Config variable set: :tmp_dir => "/tmp"
Config variable set: :default_env => {}
Config variable set: :keep_releases => 5
Config variable set: :format => :airbrussh
Config variable set: :log_level => :debug
Config variable set: :pty => false
Config variable set: :local_user => #<Proc:[email protected]:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/defaults.rb:36 (lambda)>
Config variable set: :format => :airbrussh
Config variable set: :git_shallow_clone => false
Config variable set: :git_wrapper_path => #<Proc:[email protected]:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/scm/git.rb:9 (lambda)>
Config variable set: :git_environmental_variables => #<Proc:[email protected]:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/scm/git.rb:15 (lambda)>
Config variable set: :application => "my_app_name"
Config variable set: :repo_url => "[email protected]:me/my_repo.git"
Config variable set: :scm => :git
00:00 foo:local
01 dir
cap aborted!
Errno::ENOENT: No such file or directory - /usr/bin/env dir
C:/Ruby/224/lib/ruby/2.2.0/open3.rb:193:in `spawn'
C:/Ruby/224/lib/ruby/2.2.0/open3.rb:193:in `popen_run'
C:/Ruby/224/lib/ruby/2.2.0/open3.rb:93:in `popen3'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/local.rb:44:in `execute_command'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:141:in `block in create_command_and_execute'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:141:in `tap'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:141:in `create_command_and_execute'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:74:in `execute'
C:/Users/mr/inpay_git/capdemo/lib/capistrano/tasks/foo.rake:5:in `block (3 levels) in <top (required)>'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `instance_exec'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/sshkit-1.13.1/lib/sshkit/backends/abstract.rb:29:in `run'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/dsl.rb:70:in `run_locally'
C:/Users/mr/inpay_git/capdemo/lib/capistrano/tasks/foo.rake:4:in `block (2 levels) in <top (required)>'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `call'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/airbrussh-1.2.0/lib/airbrussh/rake/context.rb:62:in `execute'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
C:/Ruby/224/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/lib/capistrano/application.rb:14:in `run'
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/capistrano-3.8.1/bin/cap:3:in `<top (required)>'
C:/Ruby/224/bin/cap:22:in `load'
C:/Ruby/224/bin/cap:22:in `<main>'
Tasks: TOP => foo:local```
好了 - 這樣的「run_locally」方法實際上並不意味着當地有關部署與正在運行的任務 - 在跨平臺環境,或者至少沒有。根據這個反饋,我編寫了我自己的部署策略,使用git archive將最新的頭部從git拉到本地存儲的tarball,並將其上傳到遠程服務器。 –
恭喜!很高興聽到你的工作。 –