简体   繁体   中英

Rails 3 Deploying to Heroku syntax error, unexpected $end

After successfully testing my "alpha" Rails 3 app in my local dev environment, I pushed it up to Heroku (Cedar) for live testing. The push was successful, but the app crashes upon startup with the following errors:

: => Booting WEBrick
: => Ctrl-C to shutdown server  
: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require':   /app/app/controllers/dives_controller.rb:50: invalid multibyte char (US-ASCII) (SyntaxError)
: /app/app/controllers/dives_controller.rb:50: syntax error, unexpected $end
: Exiting

I have checked for unexpected characters and missing end statements, but can not seem to find any. I am not using any multilingual characters (to my knowledge).

Here are a few of my files including: Gemfile, Gemfile.lock, database.yml, dives_controller.rb https://gist.github.com/2632041

Could this possibly have something to do with using postgres and not specifiying it in my database.yml correctly?

If you look at lines 50 and 51 of dives_controller.rb , you will notice some weird white-space sort of characters appearing before (they are highlighted in the github output). I have a feeling those are the characters that are causing the problem.

They may have cropped up by pressing some random keys on your keyboard by mistake. Just remove them and replace them with a space .

I'm not exactly sure why this works, but I removed the following lines in my dives_controller.rb and the app now deploys correctly:

#@user = User.where(:facebook_id => current_user.identifier) 
#@dive = @user.dives.create(params[:dive])
#@dive = Dive.new(params[:dive])

The spaces highlighted in red in the Gist file are non-breaking spaces . A nightmare for developers.
You can ask your IDE or text editor to show them in a different character.

For example, set listchars=trail:◃,nbsp:• tells VIM to display • for non-breaking spaces and ◃ for trailing spaces .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM