All threads / Capistrano deployment errors

Ask A Question


You’re not receiving notifications from this thread.

Capistrano deployment errors

Wouter van den Beld asked in Servers


I installed the working_hours gem to calculate SLA hours on my ticketsystem. It all works on dev so i was ready to deploy it to the production machine with capistrano

now i get the following errors when i run cap deploy:

DEBUG[be1a04f1] rake aborted!
DEBUG[be1a04f1] SyntaxError: /home/deploy/btapp/shared/bundle/ruby/1.9.1/gems/working_hours-1.0.2/lib/working_hours/computation.rb:7: syntax error, unexpected tLABEL
DEBUG[be1a04f1] def add_days origin, days, config: nil
DEBUG[be1a04f1] ^
DEBUG[be1a04f1] /home/deploy/btapp/shared/bundle/ruby/1.9.1/gems/working_hours-1.0.2/lib/working_hours/computation.rb:21: syntax error, unexpected tLABEL
DEBUG[be1a04f1] def add_hours origin, hours, config: nil
DEBUG[be1a04f1] ^
DEBUG[be1a04f1] /home/deploy/btapp/shared/bundle/ruby/1.9.1/gems/working_hours-1.0.2/lib/working_hours/computation.rb:26: syntax error, unexpected tLABEL
DEBUG[be1a04f1] def add_minutes origin, minutes, config: nil

i am on ruby 2.1.2 and when i run rbenv versions i dont see 1.9.1 is that normal?
i tried different gem version of working_hours but i still get the same errors,
Any ideas?

That's interesting. Is the version of Ruby running on your server the same version as the one you have locally by chance?

Yes, i did have the same versions locally and on my server i installed 2.1.5 now on both machines and i still get the same error.
I tried to install the gem on my production server in the current folder and the gem will install.

even if i go to my releasees folder and go to the latest uploaded release and run bundle the working gem will be installed.

Installing working_hours 1.0.2
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into /home/deploy/btapp/shared/bundle
[email protected]:~/btapp/releases/20141210085038$

I think (after looking at my server) that the ruby/1.9.1 folder is okay. I have a bunch of gems (420 apparently!) in that same ruby/1.9.1 folder and I've been using Ruby 2.1.5. It seems safe to ignore that bit.

The reason I think it is probably that is because the line #7 is this one and it is using the new version of the Ruby hash format

    def add_days origin, days, config: nil

Which would give you that syntax error if you were running on an older version of Ruby.

Now one thing to note here is Capistrano doesn't load up bash which means it wouldn't initialize rbenv or rvm (whichever you are using). So it is possible that if you don't have rbenv/rvm configured right in Capistrano, it may be loading a different version of Ruby that came with your server. That might be the next piece to do some debugging on.

The capistrano-rvm and/or capistrano-rbenv gems are probably the ones to take a look at here and make sure it's executing the right version during the deploy.


Thanks Chris! i got it working again. i checked my capfile and i forget to add

require 'capistrano/rbenv'

after i added this to my capfile i was getting

DEBUG[7cacbd08] Running /usr/bin/env [ ! -d /usr/local/rbenv/versions/2.1.5p273 ] on 
DEBUG[7cacbd08] Command: [ ! -d /usr/local/rbenv/versions/2.1.5p273 ]
DEBUG[7cacbd08] Finished in 0.587 seconds with exit status 0 (successful).
ERRORrbenv: 2.1.5p273 is not installed or not found in /usr/local/rbenv/versions/2.1.5p273
cap aborted!

So i looked in ~/.rbenv/versions$ and noticed the folder was named 2.1.5. so edited my capfile again from:

:rbenv_ruby, '2.1.5p273'


:rbenv_ruby, '2.1.5'

run deploy again and it all works now.

still have to run db:migrations and bundle manually so that is my next challange.

That would do it. Subtle but important! :)

This was a good find. But on a side note, in Ubuntu (and most debian based distros) the ruby1.9.1-dev package is installed ergo why you see it there. If you are running the 1.9.x version of Ruby such as I am, ruby1.9.1-dev is a requirement to get bundler and Ruby working. I ran into this problem when spinning up a new server using 1.9.3 during my capistrano deployments. A quick yielded the ruby1.9.1-dev package needing to be installed.

Probably not something you need to include in the guides since you're focusing on Edge Rails/Ruby but it's good to know for those of us who are still "old school".

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 41,443+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2021 GoRails, LLC. All rights reserved.