Syntax problem in my .rb file, prob very simple.

22 views
Skip to first unread message

Daniel Shepherd

unread,
Feb 13, 2014, 5:05:53 PM2/13/14
to capis...@googlegroups.com
Hi guys, here is my tasks.rb file from a Capistrano 2 deployment.

Ive tracked hacking it myself to include the extra feature at the bottom. Basically I want to have the two functions in db:sync but ive done something which is causing my deployment to say that db:make_config doesn't exist. So I've put "end" somewhere wrong but I'm lost as to how to sort this out, if anyone could have a quick look and fix it would be greatly appreciated.


tasks.rb

Rob Hunter

unread,
Feb 14, 2014, 2:35:41 AM2/14/14
to capis...@googlegroups.com
Daniel,

I've taken a look at the Ruby file you attached and it does indeed have a Ruby syntax error -- a couple of missing `end`s.

Every time you use a `do` in Ruby to start a block, you need a matching `end` to finish it. It's standard practice to indent everything between the `do` and `end` so you can easily tell which `end` matches which `do`.

In your `deploy.rb`:

    task :sync, :roles => :web do
      ...
    end


Likewise, when you use `if`/`then`, you'll also need an `end`.

    if ... then
      ...
    end


    if stage == :production then
      puts "[Error] ..."
    end

In the example you posted, there's an `else` instead of an `end` (and it's indented at the same level as the `puts` which makes it hard to spot).

Making these two changes (extra `end`, replace `else` with `end`) should make a syntactically OK file. If you'd like help simplifying the code itself, post back here (or try live chat with the #ruby channel on Freenode IRC): https://webchat.freenode.net/


Hunter



On 14 February 2014 09:05, Daniel Shepherd <dan.john...@gmail.com> wrote:
Hi guys, here is my tasks.rb file from a Capistrano 2 deployment.

Ive tracked hacking it myself to include the extra feature at the bottom. Basically I want to have the two functions in db:sync but ive done something which is causing my deployment to say that db:make_config doesn't exist. So I've put "end" somewhere wrong but I'm lost as to how to sort this out, if anyone could have a quick look and fix it would be greatly appreciated.


--
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 capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/a7d9f3bc-a5d8-4156-9dbd-449be55012a7%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Rob Hunter

Daniel Shepherd

unread,
Feb 14, 2014, 6:14:57 AM2/14/14
to capis...@googlegroups.com
Hi Hunter,

Thanks a lot for your reply! I had figured that the "ends" were required for each do (like opening closing brackets for php) but I just couldn't match everything up. The reason that has an else is because I copied it over from stage WP (see their tasks file attached) I tried putting it as "end" instead and added another end to the end of the file but I'm still getting syntax errors and yet I feel like I've matched every "do" and "if" up now. There is a "do" in the final block of code which is hard to find (not sure if it counts) but id tried an extra end for it as well but no luck.

I can either get no syntax errors, but deploy fails as it says the final DB tasks doesn't exist, or i just get syntax errors trying to run either task :/
(stage wp example) tasks.rb
Reply all
Reply to author
Forward
0 new messages