0

Right after running 'heroku run rake db:migrate', the error includes:

    remote:        Bundle complete! 21 Gemfile dependencies, 77 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.

    remote: sh: 2: Syntax error: Unterminated quoted string
remote: sh: 2: Syntax error: Unterminated quoted string
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     rake aborted!
remote:  !     NameError: undefined local variable or method `config' for main:Object

remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to postil9.
remote: 
To https://git.heroku.com/postil9.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/postil9.git

And here's my 'production.rb' file:

Rails.application.configure do

  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local = false
  config.action_controller.perform_caching = true
  config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.assets.digest = true
  config.log_level = :debug
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
  config.action_mailer.default_url_options = { host: "postil9.herokuapp.com"}
  config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: ENV.fetch("S3_BUCKET_NAME"),
    access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID"),
    secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"),
    s3_region: ENV.fetch("AWS_REGION"),
  }
}

  Paperclip::Attachment.default_options[:s3_host_name] = "s3-us-west-2.amazonaws.com"

end

My application.rb file:

require File.expand_path('../boot', __FILE__)

config.assets.initialize_on_precompile = false
require 'rails/all'

Bundler.require(*Rails.groups)

module Workspace
  class Application < Rails::Application


    config.active_record.raise_in_transactional_callbacks = true
  end
end

Already tried bundle install --without production, but still have no clue about the solution. The app works perfectly on the Rails server.

10
  • Can you give more information about of issue? May 28, 2018 at 22:00
  • More from the output would be useful, there is typically an error pointed out around the top, just put the whole trace in here if you could and it should help. May 28, 2018 at 22:09
  • 1
    Apparently it's a syntax error, some uncompleted quote It would be good if you put the error's output, complete to see in which file the problem is May 28, 2018 at 22:23
  • Trying to, but the site keeps asking me to add more details instead of code. There's no much more details I can add to balance with the amount of code.
    – Rony B.
    May 28, 2018 at 22:39
  • 2
    "The app works perfectly on the Rails server." - if by "rails server" you mean development mode and this is indeed so, then the problem must be in config/environments/production.rb May 28, 2018 at 23:02

1 Answer 1

1

In your application.rb file you have :

config.assets.initialize_on_precompile = false

And it's outside the application class and that's why it raising :

NameError: undefined local variable or method `config' for main:Object

because 'config' doesn't exists outside the app class, your application.rb should look like this :

require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(*Rails.groups)

module Workspace
  class Application < Rails::Application
    config.assets.initialize_on_precompile = false # Moved in app class
    config.active_record.raise_in_transactional_callbacks = true
  end
end
3
  • Thank you! It solved this problem BUT now it's pointing another one from my 'production.rb' file: rake aborted! remote: KeyError: key not found: "S3_BUCKET_NAME"
    – Rony B.
    May 29, 2018 at 14:32
  • there is this line ENV.fetch("S3_BUCKET_NAME") in your config files, which raise an error if env variable is missing, you have to set S3_BUCKET_NAME in your env
    – D1ceWard
    May 29, 2018 at 14:37
  • I see. I'll take care of it from now on. Thanks a lot, everyone!
    – Rony B.
    May 29, 2018 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.