我曾尝试将我们的capistrano2脚本升级到最新的capistrano,但是却很难让它工作起来。为了限制转换中的任何问题,我启动了一个空项目并执行了cap install。
添加了一个自定义任务以在机器上本地运行,并进行了尝试。同样的结果。
这就是我遇到的错误:Errno::ENOENT: No such file or directory - /usr/bin/env dir
确切说明:
1) mkdir capdemo
2)光盘演示
( 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,ruby 2.2.4和capistrano 3.8.1上运行
```mr@MR-LAPTOP MINGW64 ~/inpay_git/capdemo$:本地-p --跟踪
**调用暂存(first_time)
**执行阶段
**调用加载:默认值(first_time)
**执行load:默认值
**调用foo:local (first_time)
**执行foo:本地
配置变量集::print_config_variables => true
配置变量集::stage =>:stage
配置变量集::scm => :"default-git“
配置变量集::分支=>“主”
配置变量集:# (lambda)> )
配置变量集::tmp_dir => "/tmp“
配置变量集::default_env => {}
配置变量集::keep_releases => 5
配置变量集::=>格式:airbrussh
配置变量集::log_level => :debug
配置变量集::pty => false
配置变量集:# (lambda)> )
配置变量集::=>格式:airbrussh
配置变量集::git_shallow_clone => false
配置变量集:# (lambda)> )
配置变量集:# (lambda)> )
配置变量集::application => "my_app_name“
配置变量集::repo_url => "git@example.com:me/my_repo.git“
配置变量集::scm => :git
00:00 foo:本地人
01 dir帽子被取消了!
Errno::ENOENT:没有这样的文件或目录- /usr/bin/env dir
C:/ruby/224/lib/ruby/2.2.0/open3.rb:193:在“产卵”中
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:“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‘阻止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“执行”
C:/Users/mr/inpay_git/capdemo/lib/capistrano/tasks/foo.rake:5:in在中的块(3级)
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 `块(2个级别)‘
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‘阻止执行’
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in‘’
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:250:in“执行”
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/airbrussh-1.2.0/lib/airbrussh/rake/context.rb:62:in“执行”
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/task.rb:194:in‘阻止invoke_with_call_chain’
C:/ruby/224/lib/ruby/2.2.0/nanor.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‘调用’
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‘top_level中的块(2个级别)’
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108:in‘’
C:/Ruby/224/lib/ruby/gems/2.2.0/gems/rake-12.0.0/lib/rake/application.rb:108: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“运行中的阻塞”
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 `‘
C:/Ruby/224/bin/cap:22:in‘`load’
C:/Ruby/224/bin/cap:22:in
任务:顶级=> foo:local``
发布于 2017-05-05 15:31:20
默认情况下,用Capistrano执行的命令都以/usr/bin/env作为前缀。如果系统上没有/usr/bin/env,则该命令将失败。我不熟悉Windows,所以我不知道这是否是一个无法克服的问题。
如果要删除/usr/bin/env前缀,可以修改Capistrano的“命令映射”以删除所有默认行为:
# In deploy.rb
# NOT RECOMMENDED
SSHKit.config.command_map = SSHKit::CommandMap.new({})但这将影响本地和远程命令,这是不可取的。同样,Capistrano假设您希望在本地环境和远程环境中以相同的方式运行。
如果这些限制和解决办法限制太大,则不必使用run_locally。事实上,无论怎样,run_locally都不是很好地被Capistrano所支持,而且维护人员(包括我自己)也支持劝阻使用它。相反,您可以使用Ruby的内置方法来运行本地命令,比如system或back。
http://ruby-doc.org/core-2.4.1/Kernel.html#method-i-system
http://ruby-doc.org/core-2.4.1/Kernel.html#method-i-60
https://stackoverflow.com/questions/43762345
复制相似问题