File.open is executed on the machine RUNNING capistrano not the remote
machines.

You need to use a method like 'put' to do what it looks like you are
intendeding

https://github.com/capistrano/capistrano/wiki/2.x-DSL-Action-File-Transfer-Put

task :update_locals do
  options_hash =  { key1: value1 }
  put options_hash.to_yaml, "#{latest_release}/config/locals.yml"
end

Also, use 'latest_release' instead of 'current_path'. If you call your
current task during a deploy (and it had actually worked) you would have
written the file to release directory that is about to be replaced, rather
than the one being actually deployed to.

There are actually very few valid reasons to use ANY other method than
#{latest_release} in your recipes to target something to happen in your
release directory.

from:
https://github.com/capistrano/capistrano/blob/master/lib/capistrano/recipes/deploy.rb

# some tasks, like symlink, need to always point at the latest release, but
# they can also (occassionally) be called standalone. In the standalone case,
# the timestamped release_path will be inaccurate, since the directory won't
# actually exist. This variable lets tasks like symlink work either in the
# standalone case, or during deployment.
_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path :
current_release }


On Wed, Jan 30, 2013 at 7:19 PM, macsig <[email protected]> wrote:

> Hello there.
> I'm trying to write my first very simple capistrano recipe that updates a
> value stored in a yml file.
>
> The recipe is simple as:
>
> task :update_locals do
>   options_hash = { key1: value1 }
>   File.open("#{current_path}/config/locals.yml", 'w+') {|f|
> f.write(options_hash.to_yaml) }
> end
>
> But when I run it I get
>
> `initialize': Input/output error -
> /home/userx/apps/appx/current/config/locals.yml (Errno::EIO)
>
> Am I missing something?
>
> I'm running ruby 1.9.3 and capistrano 2.14.1
>
>
>
> Thanks for the help and have a good day.
>
> --
> --
> * You received this message because you are subscribed to the Google
> Groups "Capistrano" group.
> * To post to this group, send email to [email protected]
> * To unsubscribe from this group, send email to
> [email protected] For more options, visit this
> group at http://groups.google.com/group/capistrano?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Capistrano" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
* You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
* To post to this group, send email to [email protected]
* To unsubscribe from this group, send email to 
[email protected] For more options, visit this group at 
http://groups.google.com/group/capistrano?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to