# Deployment syntax error: fine in dev - what's happening?

**URL:** <https://www.ruby-forum.com/t/deployment-syntax-error-fine-in-dev-whats-happening/177778>\
**Category:** Rails\
**Created:** [October 23, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/deployment-syntax-error-fine-in-dev-whats-happening/177778 "2009-10-23T15:57:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snowbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@snowbug](https://www.ruby-forum.com/u/snowbug)\
**Post date:** [October 23, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/deployment-syntax-error-fine-in-dev-whats-happening/177778/1 "2009-10-23T15:57:16Z")

</div>

I’m deploying an app (using Capistrano) to a staging server prior to  
final deployment. The app runs fine in dev, but in staging it throws a  
syntax error. How can that be?

The error is:

/Library/Ruby/Site/1.8/rubygems/custom\_require.rb:31:in  
`gem\_original\_require’:  
/Library/WebServer/staging.givetothem.co.uk/releases/20091023133654/app/controllers/bulkimport\_controller.rb:32:  
syntax error, unexpected kRESCUE, expecting kEND (SyntaxError)  
rescue Exception  
^

The code generating the error is:

```
  begin
    @parsed_file=CSV::Reader.parse(params[:dump][:file])
    n=0
    @parsed_file.each do |row|
    unless row[0].nil?
      c=@recipients.new
      c.address=row[0]
      if c.save
        n=n+1
        GC.start if n%50==0
      end
    end
  rescue Exception
    flash.now[:error]="Import failed! Please check the file and try

```

again."  
else  
flash.now[:notice]=“Import successful, #{n} new addresses added  
to your list.”  
end

Another couple errors are then thrown: two lines further complaining  
about the else, then at EOF still expecting kEND.

I can’t see it, and textmate suggests I’ve all my starts and ends lined  
up. What am I doing wrong? And more importantly, does anyone have any  
idea why is is showing in staging only and not in my dev environment?

Rails is 2.3.4 on both, Ruby is 1.8.7pl72, gems are frozen in, OSes is  
OSX Snow Leopard & Snow Leopard server.

Thanks in advance for any help - I’m a relative newb at this.

Alan.

---

<div class="post-metadata">

**Author:** ![snowbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@snowbug](https://www.ruby-forum.com/u/snowbug)\
**Post date:** [October 24, 2009, 1:46pm UTC](https://www.ruby-forum.com/t/deployment-syntax-error-fine-in-dev-whats-happening/177778/2 "2009-10-24T13:46:48Z")

</div>

Frederick C. wrote:

> Well the code looks wrong to me

Indeed it is. I’m clearly blind. Thanks also for the info on the  
environmental differences. Makes perfect sense now.

---

<div class="post-metadata">

**Author:** ![snowbug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@snowbug](https://www.ruby-forum.com/u/snowbug)\
**Post date:** [October 23, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/deployment-syntax-error-fine-in-dev-whats-happening/177778/3 "2009-10-23T16:41:42Z")

</div>

On Oct 23, 2:57 pm, Alan F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m deploying an app (using Capistrano) to a staging server prior to  
> final deployment. The app runs fine in dev, but in staging it throws a  
> syntax error. How can that be?

Well the code looks wrong to me - inside the begin you have each  
unless and if, but only 2 ends before the rescue (you don’t seem to  
have indented the each).  
A big difference between development and production is that in  
development files are loaded when needed, so if there is a syntax  
error you hear about it when that file is used, whereas in production  
rails loads all your classes up front so you get the error upon  
startup.

Fred
