Permalink
Browse files

use mkmf's find_executable to test for local commands so that it also…

… works on windows #117
  • Loading branch information...
1 parent 7497ab0 commit 003f453f3604f6d84f15f31842c1f7e79aca7af3 @jweiss jweiss committed Oct 8, 2009
Showing with 49 additions and 1 deletion.
  1. +47 −0 capistrano.gemspec
  2. +2 −1 lib/capistrano/recipes/deploy.rb
View
@@ -0,0 +1,47 @@
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{capistrano}
+ s.version = "2.5.9"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jamis Buck, Lee Hambley"]
+ s.date = %q{2009-10-08}
+ s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
+ s.email = ["jamis@jamisbuck.org", "lee.hambley@gmail.com"]
+ s.executables = ["cap", "capify"]
+ s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/capistrano/callback.rb", "lib/capistrano/cli/execute.rb", "lib/capistrano/cli/help.rb", "lib/capistrano/cli/help.txt", "lib/capistrano/cli/options.rb", "lib/capistrano/cli/ui.rb", "lib/capistrano/cli.rb", "lib/capistrano/command.rb", "lib/capistrano/configuration/actions/file_transfer.rb", "lib/capistrano/configuration/actions/inspect.rb", "lib/capistrano/configuration/actions/invocation.rb", "lib/capistrano/configuration/callbacks.rb", "lib/capistrano/configuration/connections.rb", "lib/capistrano/configuration/execution.rb", "lib/capistrano/configuration/loading.rb", "lib/capistrano/configuration/namespaces.rb", "lib/capistrano/configuration/roles.rb", "lib/capistrano/configuration/servers.rb", "lib/capistrano/configuration/variables.rb", "lib/capistrano/configuration.rb", "lib/capistrano/errors.rb", "lib/capistrano/extensions.rb", "lib/capistrano/logger.rb", "lib/capistrano/processable.rb", "lib/capistrano/recipes/compat.rb", "lib/capistrano/recipes/deploy/dependencies.rb", "lib/capistrano/recipes/deploy/local_dependency.rb", "lib/capistrano/recipes/deploy/remote_dependency.rb", "lib/capistrano/recipes/deploy/scm/accurev.rb", "lib/capistrano/recipes/deploy/scm/base.rb", "lib/capistrano/recipes/deploy/scm/bzr.rb", "lib/capistrano/recipes/deploy/scm/cvs.rb", "lib/capistrano/recipes/deploy/scm/darcs.rb", "lib/capistrano/recipes/deploy/scm/git.rb", "lib/capistrano/recipes/deploy/scm/mercurial.rb", "lib/capistrano/recipes/deploy/scm/none.rb", "lib/capistrano/recipes/deploy/scm/perforce.rb", "lib/capistrano/recipes/deploy/scm/subversion.rb", "lib/capistrano/recipes/deploy/scm.rb", "lib/capistrano/recipes/deploy/strategy/base.rb", "lib/capistrano/recipes/deploy/strategy/checkout.rb", "lib/capistrano/recipes/deploy/strategy/copy.rb", "lib/capistrano/recipes/deploy/strategy/export.rb", "lib/capistrano/recipes/deploy/strategy/remote.rb", "lib/capistrano/recipes/deploy/strategy/remote_cache.rb", "lib/capistrano/recipes/deploy/strategy.rb", "lib/capistrano/recipes/deploy/templates/maintenance.rhtml", "lib/capistrano/recipes/deploy.rb", "lib/capistrano/recipes/standard.rb", "lib/capistrano/recipes/templates/maintenance.rhtml", "lib/capistrano/recipes/upgrade.rb", "lib/capistrano/role.rb", "lib/capistrano/server_definition.rb", "lib/capistrano/shell.rb", "lib/capistrano/ssh.rb", "lib/capistrano/task_definition.rb", "lib/capistrano/transfer.rb", "lib/capistrano/version.rb", "lib/capistrano.rb", "README.rdoc"]
+ s.files = ["bin/cap", "bin/capify", "CHANGELOG.rdoc", "examples/sample.rb", "lib/capistrano/callback.rb", "lib/capistrano/cli/execute.rb", "lib/capistrano/cli/help.rb", "lib/capistrano/cli/help.txt", "lib/capistrano/cli/options.rb", "lib/capistrano/cli/ui.rb", "lib/capistrano/cli.rb", "lib/capistrano/command.rb", "lib/capistrano/configuration/actions/file_transfer.rb", "lib/capistrano/configuration/actions/inspect.rb", "lib/capistrano/configuration/actions/invocation.rb", "lib/capistrano/configuration/callbacks.rb", "lib/capistrano/configuration/connections.rb", "lib/capistrano/configuration/execution.rb", "lib/capistrano/configuration/loading.rb", "lib/capistrano/configuration/namespaces.rb", "lib/capistrano/configuration/roles.rb", "lib/capistrano/configuration/servers.rb", "lib/capistrano/configuration/variables.rb", "lib/capistrano/configuration.rb", "lib/capistrano/errors.rb", "lib/capistrano/extensions.rb", "lib/capistrano/logger.rb", "lib/capistrano/processable.rb", "lib/capistrano/recipes/compat.rb", "lib/capistrano/recipes/deploy/dependencies.rb", "lib/capistrano/recipes/deploy/local_dependency.rb", "lib/capistrano/recipes/deploy/remote_dependency.rb", "lib/capistrano/recipes/deploy/scm/accurev.rb", "lib/capistrano/recipes/deploy/scm/base.rb", "lib/capistrano/recipes/deploy/scm/bzr.rb", "lib/capistrano/recipes/deploy/scm/cvs.rb", "lib/capistrano/recipes/deploy/scm/darcs.rb", "lib/capistrano/recipes/deploy/scm/git.rb", "lib/capistrano/recipes/deploy/scm/mercurial.rb", "lib/capistrano/recipes/deploy/scm/none.rb", "lib/capistrano/recipes/deploy/scm/perforce.rb", "lib/capistrano/recipes/deploy/scm/subversion.rb", "lib/capistrano/recipes/deploy/scm.rb", "lib/capistrano/recipes/deploy/strategy/base.rb", "lib/capistrano/recipes/deploy/strategy/checkout.rb", "lib/capistrano/recipes/deploy/strategy/copy.rb", "lib/capistrano/recipes/deploy/strategy/export.rb", "lib/capistrano/recipes/deploy/strategy/remote.rb", "lib/capistrano/recipes/deploy/strategy/remote_cache.rb", "lib/capistrano/recipes/deploy/strategy.rb", "lib/capistrano/recipes/deploy/templates/maintenance.rhtml", "lib/capistrano/recipes/deploy.rb", "lib/capistrano/recipes/standard.rb", "lib/capistrano/recipes/templates/maintenance.rhtml", "lib/capistrano/recipes/upgrade.rb", "lib/capistrano/role.rb", "lib/capistrano/server_definition.rb", "lib/capistrano/shell.rb", "lib/capistrano/ssh.rb", "lib/capistrano/task_definition.rb", "lib/capistrano/transfer.rb", "lib/capistrano/version.rb", "lib/capistrano.rb", "Rakefile", "README.rdoc", "setup.rb", "test/cli/execute_test.rb", "test/cli/help_test.rb", "test/cli/options_test.rb", "test/cli/ui_test.rb", "test/cli_test.rb", "test/command_test.rb", "test/configuration/actions/file_transfer_test.rb", "test/configuration/actions/inspect_test.rb", "test/configuration/actions/invocation_test.rb", "test/configuration/callbacks_test.rb", "test/configuration/connections_test.rb", "test/configuration/execution_test.rb", "test/configuration/loading_test.rb", "test/configuration/namespace_dsl_test.rb", "test/configuration/roles_test.rb", "test/configuration/servers_test.rb", "test/configuration/variables_test.rb", "test/configuration_test.rb", "test/deploy/local_dependency_test.rb", "test/deploy/remote_dependency_test.rb", "test/deploy/scm/accurev_test.rb", "test/deploy/scm/base_test.rb", "test/deploy/scm/git_test.rb", "test/deploy/scm/mercurial_test.rb", "test/deploy/strategy/copy_test.rb", "test/extensions_test.rb", "test/fixtures/cli_integration.rb", "test/fixtures/config.rb", "test/fixtures/custom.rb", "test/logger_test.rb", "test/role_test.rb", "test/server_definition_test.rb", "test/shell_test.rb", "test/ssh_test.rb", "test/task_definition_test.rb", "test/transfer_test.rb", "test/utils.rb", "Manifest", "capistrano.gemspec", "test/deploy/scm/none_test.rb", "test/deploy/scm/subversion_test.rb"]
+ s.homepage = %q{http://www.capify.org}
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano", "--main", "README.rdoc"]
+ s.require_paths = ["lib"]
+ s.rubyforge_project = %q{capistrano}
+ s.rubygems_version = %q{1.3.4}
+ s.summary = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.}
+ s.test_files = ["test/cli/execute_test.rb", "test/cli/help_test.rb", "test/cli/options_test.rb", "test/cli/ui_test.rb", "test/cli_test.rb", "test/command_test.rb", "test/configuration/actions/file_transfer_test.rb", "test/configuration/actions/inspect_test.rb", "test/configuration/actions/invocation_test.rb", "test/configuration/callbacks_test.rb", "test/configuration/connections_test.rb", "test/configuration/execution_test.rb", "test/configuration/loading_test.rb", "test/configuration/namespace_dsl_test.rb", "test/configuration/roles_test.rb", "test/configuration/servers_test.rb", "test/configuration/variables_test.rb", "test/configuration_test.rb", "test/deploy/local_dependency_test.rb", "test/deploy/remote_dependency_test.rb", "test/deploy/scm/accurev_test.rb", "test/deploy/scm/base_test.rb", "test/deploy/scm/git_test.rb", "test/deploy/scm/mercurial_test.rb", "test/deploy/scm/none_test.rb", "test/deploy/scm/subversion_test.rb", "test/deploy/strategy/copy_test.rb", "test/extensions_test.rb", "test/logger_test.rb", "test/role_test.rb", "test/server_definition_test.rb", "test/shell_test.rb", "test/ssh_test.rb", "test/task_definition_test.rb", "test/transfer_test.rb"]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<net-ssh>, [">= 2.0.14"])
+ s.add_runtime_dependency(%q<net-sftp>, [">= 2.0.0"])
+ s.add_runtime_dependency(%q<net-scp>, [">= 1.0.0"])
+ s.add_runtime_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
+ s.add_runtime_dependency(%q<highline>, [">= 0"])
+ else
+ s.add_dependency(%q<net-ssh>, [">= 2.0.14"])
+ s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
+ s.add_dependency(%q<net-scp>, [">= 1.0.0"])
+ s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
+ s.add_dependency(%q<highline>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<net-ssh>, [">= 2.0.14"])
+ s.add_dependency(%q<net-sftp>, [">= 2.0.0"])
+ s.add_dependency(%q<net-scp>, [">= 1.0.0"])
+ s.add_dependency(%q<net-ssh-gateway>, [">= 1.0.0"])
+ s.add_dependency(%q<highline>, [">= 0"])
+ end
+end
@@ -1,4 +1,5 @@
require 'yaml'
+require 'mkmf'
require 'capistrano/recipes/deploy/scm'
require 'capistrano/recipes/deploy/strategy'
@@ -101,7 +102,7 @@ def run_locally(cmd)
# tests if the given command is present on the local system
def command_present?(cmd)
executable = cmd.to_s.split(" ").first
- unless system("which #{executable}")
+ unless find_executable(executable)
logger.important "executable '#{executable}' not present or not in $PATH on the local system!"
end
end

14 comments on commit 003f453

@mguterl

This commit causes an mkmf.log to be creating each time I deploy, it is rather annoying to say the least. I know I can add it to my .gitignore, but it should probably be handled in capistrano.

@jweiss
jweiss commented on 003f453 Nov 17, 2009

I agree, I'll see that I fix it

@jweiss
jweiss commented on 003f453 Nov 17, 2009

I cannot reproduce the creation of mkmf.log, in which directory is it created?

@ledermann

It's created in RAILS_ROOT.
My environment: OS X 10.5.8, Ruby 1.8.7p174, Rails 2.3.4

@mguterl

It is created in RAILS_ROOT for me also.

OS X 10.6.2
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.0.0], MBARI 0x6770, Ruby Enterprise Edition 20090928
Rails 2.3.2

@kron4eg

and for me too

ubuntu 9.10
ruby 1.8.7
rails 2.3.4
capistrano 2.5.10

@kron4eg

$ cat mkmf.log
find_executable: checking for git... -------------------- yes


@rgo
rgo commented on 003f453 Nov 18, 2009

Same for me too. Jonathan should we open a ticket for it in lighthouse?

Slackware 13 - 64 bits
ruby 1.8.6 (2009-03-31 patchlevel 368) [x86_64-linux]
rails 2.1.0
capistrano 2.5.10

@leehambley
Member

@rgo - ticket already opened at https://capistrano.lighthouseapp.com/projects/8716/tickets/127 - lets take this discussion there. (so people can see it, rather than it being hidden in a commit message annotation thread)

@jweiss
jweiss commented on 003f453 Nov 18, 2009

I fixed this in http://github.com/capistrano/capistrano/commit/5a676ba1ee80665f2dfa3f2c658d5200074040f0

Can you guys please update and verify?

Thanks!

@ledermann

I have modified my local capistrano gem with your commit - now there are is no more "mkmf.log" after deployment. So your change works for me.

@leehambley
Member

Still not happy with the solution, we couldn't replicate the original issue that lead to this mkmf patch being introduced in the first instance.

@jweiss
jweiss commented on 003f453 Nov 22, 2009

The problem is that Capistrano relies on local commands to just work and is not very verbose and correct with the error message. So checking if a local command exists prevents at least those cases. We could port the mfms functionalitiy but we should also make sure Capistrano prints the stderr it receives from local commands and what it thinks it means (sometimes they differ like in the blog post above).

@awd
awd commented on 003f453 Nov 22, 2009

This is happening for me as well, on the following system:

Debian Lenny 5.0.3
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
Rails 2.3.4
Capistrano v2.5.10

Please sign in to comment.