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

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?
      [email protected]
      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.

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.

On Oct 23, 2:57 pm, Alan F. [email protected]
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