capture does not use within directory

20 views
Skip to first unread message

ruud

unread,
Sep 25, 2014, 8:01:47 AM9/25/14
to capis...@googlegroups.com
Versions:
  • Ruby 1.9.3
  • Capistrano 3.2.1
Platform:
  • debian wheezy
  • debian testing

hello group,

When I run this Capfile

require 'capistrano/setup'
require 'capistrano/deploy'

namespace :erik do
    desc "deploy on eriks pc"

    task :rvm do
        on roles( :app) do |host|
            within '/data/archief/current/rails' do
                versie = capture( 'rvm current' )
                puts 'version is ' + versie
                execute 'rvm', 'current'
            end
        end
    end
end


I get this output, which  shows that the capture command is NOT using the within dir (whereas the following execute does):

DEBUG[3efff16c] Running /usr/bin/env if test ! -d /data/archief/current/rails; then echo "Directory does not exist '/data/archief/current/rails'" 1>&2; false; fi on erik
DEBUG[3efff16c] Command: if test ! -d /data/archief/current/rails; then echo "Directory does not exist '/data/archief/current/rails'" 1>&2; false; fi
DEBUG[3efff16c] Finished in 10.413 seconds with exit status 0 (successful).
DEBUG[728cbcf9] Running /usr/bin/env rvm current on erik
DEBUG[728cbcf9] Command: rvm current
DEBUG[728cbcf9]         ruby-2.0.0-p353
DEBUG[728cbcf9] Finished in 0.328 seconds with exit status 0 (successful).
version is ruby-2.0.0-p353
INFO[1d833729] Running /usr/bin/env rvm current on erik
DEBUG[1d833729] Command: cd /data/archief/current/rails && /usr/bin/env rvm current
DEBUG[1d833729]         Using /home/deploy/.rvm/gems/ruby-1.9.3-p484
DEBUG[1d833729]         ruby-1.9.3-p484@rails32
DEBUG[1d833729]         Using /home/deploy/.rvm/gems/ruby-1.9.3-p484
INFO[1d833729] Finished in 1.055 seconds with exit status 0 (successful).

Who can explain what I'm doing wrong?

thanks in advance, Ruud


ruud

unread,
Sep 25, 2014, 10:34:39 AM9/25/14
to capis...@googlegroups.com
 Found it. A similar post made me try the capture without spaces, with an array, like

  versie = capture( 'rvm', 'current' )

Which DOES work, that is, the command is prepended by a cd. Not sure if this is a bug, or a feature. Nevertheless I'm glad I got it working.

Ruud



        on roles( :app) do |host|
            within '/data/archief/current/rails' do
                versie = capture( 'rvm current' )
                puts 'version is ' + versie
                execute 'rvm', 'current'
            end
        end


output is now (snippet)
DEBUG[d49114d7] Running /usr/bin/env rvm current on erik
DEBUG[d49114d7] Command: cd /data/archief/current/rails && /usr/bin/env rvm current
DEBUG[d49114d7]         Using /home/deploy/.rvm/gems/ruby-1.9.3-p484
DEBUG[d49114d7]         ruby-1.9.3-p484@rails32
DEBUG[d49114d7]         Using /home/deploy/.rvm/gems/ruby-1.9.3-p484
DEBUG[d49114d7] Finished in 1.059 seconds with exit status 0 (successful).
versie is ruby-1.9.3-p484@rails32

 
Reply all
Reply to author
Forward
0 new messages