File.exists?() in deploy.rb

893 views
Skip to first unread message

susfour

unread,
Aug 16, 2007, 3:35:15 PM8/16/07
to Capistrano
in a cap task, if I 'puts File.exists?(current_path)' I get false
returned! Why is that?

I've got a task that creates a directory in :after_symlink. when I
cap deploy, this mkdir works fine. But when I cap deploy:migrations,
the mkdir fails saying that the file already exists. I added an
unless File.exists on the run command for the directory I'm creating,
but it continues to try to run the mkdir.

Can anyone explain what's going on?

Jamis Buck

unread,
Aug 16, 2007, 3:41:42 PM8/16/07
to capis...@googlegroups.com
Because File.exists?() tests on the local machine, and current_path
exists on the remote machine.

Try running that task after update_code, instead of after symlink.
That way it will get called at the right time for your migration to
see it.

- Jamis

Sean Cribbs

unread,
Aug 16, 2007, 3:42:49 PM8/16/07
to capis...@googlegroups.com
Since that's regular Ruby code and not inside a remote execution call,
you are executing that on your local machine.

Sean

susfour

unread,
Aug 16, 2007, 5:40:25 PM8/16/07
to Capistrano
of course. I knew it was something simple. thanks guys.

On Aug 16, 2:41 pm, "Jamis Buck" <ja...@37signals.com> wrote:
> Because File.exists?() tests on the local machine, and current_path
> exists on the remote machine.
>
> Try running that task after update_code, instead of after symlink.
> That way it will get called at the right time for your migration to
> see it.
>
> - Jamis
>

Reply all
Reply to author
Forward
0 new messages