Search code examples
ruby-on-railsrubyherokuspring-gem

Heroku deployment crash rails server syntax error File.expand_path("../spring", __FILE__)


When deploying on Heroku, the server crashes with this information rails server syntax error File.expand_path("../spring", FILE) though everything is working when working locally. Here is my rail file

begin
  load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH=File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

Do you have any idea of the issue? Thanks


Solution

  • Found the solution after 1/2 day of struggling You need the following line at the top of the rail file: #!/usr/bin/env ruby Surprisingly, it wasn't a problem locally but when deploying on Heroku it was.