DanRio
DanRio

Reputation: 473

Error pushing to Heroku with Rails - sh: 2: Syntax error: Unterminated quoted string

I'm using rails and trying to push my app to Heroku. I've made various apps before and never ran into this problem. I've spent hours searching for the cause of the problem and just cannot figure it out. I've ran bundle install, bundle update, removed Heroku .env variables, nothing helps.

When I run git push heroku master I get the following error:

    git push heroku
    Counting objects: 24, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (24/24), done.
    Writing objects: 100% (24/24), 4.10 KiB | 0 bytes/s, done.
    Total 24 (delta 14), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote:
    remote: -----> Fetching set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/ruby.tgz
    remote: -----> Ruby app detected
    remote: -----> Compiling Ruby/Rails
    remote: -----> Using Ruby version: ruby-2.2.4
    remote: -----> Installing dependencies using bundler 1.11.2
    remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
    remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
    remote:        Fetching gem metadata from https://rubygems.org/...........
    remote:        Fetching version metadata from https://rubygems.org/...
    remote:        Fetching dependency metadata from https://rubygems.org/..
    remote:        Installing i18n 0.7.0
    remote:        Installing json 1.8.3 with native extensions
    remote:        Installing rake 11.2.2
    remote:        Installing minitest 5.9.0
    remote:        Installing thread_safe 0.3.5
    remote:        Installing builder 3.2.2
    remote:        Installing erubis 2.7.0
    remote:        Installing mini_portile2 2.1.0
    remote:        Installing pkg-config 1.1.7
    remote:        Installing rack 1.6.4
    remote:        Using bundler 1.11.2
    remote:        Installing mime-types-data 3.2016.0521
    remote:        Installing arel 6.0.3
    remote:        Installing thor 0.19.1
    remote:        Installing concurrent-ruby 1.0.2
    remote:        Installing execjs 2.7.0
    remote:        Installing sass 3.4.22
    remote:        Installing coffee-script-source 1.10.0
    remote:        Installing high_voltage 2.4.0
    remote:        Installing multi_json 1.12.1
    remote:        Installing turbolinks-source 5.0.0
    remote:        Installing libv8 3.16.14.15
    remote:        Installing pg 0.17.1 with native extensions
    remote:        Installing rails_serve_static_assets 0.0.5
    remote:        Installing rails_stdout_logging 0.0.4
    remote:        Installing ref 2.0.0
    remote:        Installing tilt 2.0.5
    remote:        Installing tzinfo 1.2.2
    remote:        Installing rdoc 4.2.2
    remote:        Installing nokogiri 1.6.8 with native extensions
    remote:        Installing rack-test 0.6.3
    remote:        Installing heroku-deflater 0.6.2
    remote:        Installing puma 2.11.1 with native extensions
    remote:        Installing mime-types 3.1
    remote:        Installing autoprefixer-rails 6.3.7
    remote:        Installing uglifier 3.0.0
    remote:        Installing sprockets 3.6.3
    remote:        Installing coffee-script 2.4.1
    remote:        Installing turbolinks 5.0.0
    remote:        Installing rails_12factor 0.0.2
    remote:        Installing therubyracer 0.12.2 with native extensions
    remote:        Installing activesupport 4.2.6
    remote:        Installing sdoc 0.4.0
    remote:        Installing mail 2.6.4
    remote:        Installing bootstrap-sass 3.3.6
    remote:        Installing loofah 2.0.3
    remote:        Installing rails-deprecated_sanitizer 1.0.3
    remote:        Installing globalid 0.3.6
    remote:        Installing activemodel 4.2.6
    remote:        Installing jbuilder 2.5.0
    remote:        Installing rails-html-sanitizer 1.0.3
    remote:        Installing rails-dom-testing 1.0.7
    remote:        Installing activejob 4.2.6
    remote:        Installing activerecord 4.2.6
    remote:        Installing actionview 4.2.6
    remote:        Installing actionpack 4.2.6
    remote:        Installing actionmailer 4.2.6
    remote:        Installing railties 4.2.6
    remote:        Installing sprockets-rails 3.1.1
    remote:        Installing coffee-rails 4.2.1
    remote:        Installing font-awesome-rails 4.6.3.1
    remote:        Installing jquery-rails 4.1.1
    remote:        Installing jquery-turbolinks 2.1.0
    remote:        Installing rails 4.2.6
    remote:        Installing sass-rails 5.0.5
    remote:        Installing animate-rails 1.0.10
    remote:        Bundle complete! 28 Gemfile dependencies, 66 gems now installed.
    remote:        Gems in the groups development and test were not installed.
    remote:        Bundled gems are installed into ./vendor/bundle.
    remote:        Post-install message from rdoc:
    remote:        Depending on your version of ruby, you may need to install ruby rdoc/ri data:
    remote:        <= 1.8.6 : unsupported
    remote:        = 1.8.7 : gem install rdoc-data; rdoc-data --install
    remote:        = 1.9.1 : gem install rdoc-data; rdoc-data --install
    remote:        >= 1.9.2 : nothing to do! Yay!
    remote:        Bundle completed (33.65s)
    remote:        Cleaning up the bundler cache.
    remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
    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:  !     LoadError: cannot load such file -- /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/config/application
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/Rakefile:4:in `require'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/Rakefile:4:in `<top (required)>'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load_rakefile'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:686:in `raw_load_rakefile'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:96:in `block in load_rakefile'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:95:in `load_rakefile'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:79:in `block in run'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:178:in `standard_exception_handling'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/application.rb:77:in `run'
    remote:  !     /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/exe/rake:27:in `<top (required)>'
    remote:  !     vendor/bundle/bin/rake:16:in `load'
    remote:  !     vendor/bundle/bin/rake:16:in `<main>'
    remote:  !
    remote: /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/helpers/rake_runner.rb:102:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
    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: LoadError: cannot load such file -- /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/config/application
    remote: /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/Rakefile:4:in `require'
    remote: /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/Rakefile:4:in `<top (required)>'
    remote: /tmp/build_0f0d17123ff56c25b8d1a82d83ea67c6/vendor/bundle/ruby/2.2.0/gems/rake-11.2.2/lib/rake/rake_module.rb:28:in `load'

    remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:17:in `block in instrument'
    remote:     from /app/vendor/ruby-2.3.1/lib/ruby/2.3.0/benchmark.rb:308:in `realtime'
    remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:16:in `instrument'
    remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/lib/language_pack/instrument.rb:35:in `trace'
    remote:     from /app/tmp/buildpacks/f6d48d8a14fccbb19c0c0402fca224929d18e9ee042b3e204bc5992612e990d3b3a0fb1f9627b1a3bae11e9fa20dffc96e136bd734a2f3cf92a0d05bedd42cfe/bin/compile:11:in `<main>'
    remote:  !     Push rejected, failed to compile Ruby app.
    remote:
    remote:  !     Push failed
    remote: Verifying deploy...
    remote:
    remote: !   Push rejected to fast-dawn-92173.
    remote:
    To https://git.heroku.com/fast-dawn-92173.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/fast-dawn-92173.git'

and here is my gemfile

    source 'https://rubygems.org'

    gem 'rails'
    gem 'bootstrap-sass'
    gem 'sass-rails'
    gem 'therubyracer'
    gem 'uglifier', '>= 1.3.0'
    gem 'coffee-rails'
    gem 'jquery-rails'
    gem 'turbolinks'
    gem 'jbuilder'
    gem 'sdoc', '0.4.0', group: :doc
    gem 'font-awesome-rails'
    gem 'high_voltage', '~> 2.4.0'
    gem 'sprockets-rails', require: 'sprockets/railtie'
    gem 'jquery-turbolinks'
    gem 'animate-rails'

    group :development, :test do
        gem 'sqlite3'
        gem 'byebug'
        gem 'web-console'
        gem 'spring'
        gem 'better_errors'
        gem 'letter_opener'
    end

    group :test do
        gem 'minitest-reporters', '1.0.5'
        gem 'mini_backtrace',     '0.1.3'
        gem 'guard-minitest',     '2.3.1'
    end

    group :production do
        gem 'pg', '0.17.1'
        gem 'rails_12factor', '0.0.2'
        gem 'puma',           '2.11.1'
        gem 'heroku-deflater'
    end

Everything is working fine on localhost but just can't push to heroku. Please let me know if you need anything else. Any help would be great thanks!!

As mentioned in a question it could be something to do with the .bundle/config. I deleted that which didn't changed anything, my output from bundle config is:

        Settings are listed in order of priority. The top value will be used.
    orig_path
    Set via BUNDLE_ORIG_PATH: "/Users/luisaczc/.rvm/gems/ruby-2.2.3/bin:/Users/luisaczc/.rvm/gems/ruby-2.2.3@global/bin:/Users/luisaczc/.rvm/rubies/ruby-2.2.3/bin:/usr/local/heroku/bin:/Users/luisaczc/.rbenv/shims:/Users/luisaczc/.rbenv/shims:/Users/luisaczc/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/luisaczc/.rvm/bin"

    orig_gem_path
    Set via BUNDLE_ORIG_GEM_PATH: "/Users/luisaczc/.rvm/gems/ruby-2.2.3:/Users/luisaczc/.rvm/gems/ruby-2.2.3@global"

Also here is my Gemfile.lock as requested: (Please note I had to remove a small part of the unimportant heroku push error messages as I had used the maximum stack overflow body chars)

  GEM
    remote: https://rubygems.org/
    specs:
      actionmailer (4.2.7)
        actionpack (= 4.2.7)
        actionview (= 4.2.7)
        activejob (= 4.2.7)
        mail (~> 2.5, >= 2.5.4)
        rails-dom-testing (~> 1.0, >= 1.0.5)
      actionpack (4.2.7)
        actionview (= 4.2.7)
        activesupport (= 4.2.7)
        rack (~> 1.6)
        rack-test (~> 0.6.2)
        rails-dom-testing (~> 1.0, >= 1.0.5)
        rails-html-sanitizer (~> 1.0, >= 1.0.2)
      actionview (4.2.7)
        activesupport (= 4.2.7)
        builder (~> 3.1)
        erubis (~> 2.7.0)
        rails-dom-testing (~> 1.0, >= 1.0.5)
        rails-html-sanitizer (~> 1.0, >= 1.0.2)
      activejob (4.2.7)
        activesupport (= 4.2.7)
        globalid (>= 0.3.0)
      activemodel (4.2.7)
        activesupport (= 4.2.7)
        builder (~> 3.1)
      activerecord (4.2.7)
        activemodel (= 4.2.7)
        activesupport (= 4.2.7)
        arel (~> 6.0)
      activesupport (4.2.7)
        i18n (~> 0.7)
        json (~> 1.7, >= 1.7.7)
        minitest (~> 5.1)
        thread_safe (~> 0.3, >= 0.3.4)
        tzinfo (~> 1.1)
      addressable (2.4.0)
      animate-rails (1.0.10)
        rails
      ansi (1.5.0)
      arel (6.0.3)
      autoprefixer-rails (6.3.7)
        execjs
      better_errors (2.1.1)
        coderay (>= 1.0.0)
        erubis (>= 2.6.6)
        rack (>= 0.9.0)
      bootstrap-sass (3.3.6)
        autoprefixer-rails (>= 5.2.1)
        sass (>= 3.3.4)
      builder (3.2.2)
      byebug (9.0.5)
      coderay (1.1.1)
      coffee-rails (4.2.1)
        coffee-script (>= 2.2.0)
        railties (>= 4.0.0, < 5.2.x)
      coffee-script (2.4.1)
        coffee-script-source
        execjs
      coffee-script-source (1.10.0)
      concurrent-ruby (1.0.2)
      debug_inspector (0.0.2)
      erubis (2.7.0)
      execjs (2.7.0)
      ffi (1.9.14)
      font-awesome-rails (4.6.3.1)
        railties (>= 3.2, < 5.1)
      formatador (0.2.5)
      globalid (0.3.6)
        activesupport (>= 4.1.0)
      guard (2.14.0)
        formatador (>= 0.2.4)
        listen (>= 2.7, < 4.0)
        lumberjack (~> 1.0)
        nenv (~> 0.1)
        notiffany (~> 0.0)
        pry (>= 0.9.12)
        shellany (~> 0.0)
        thor (>= 0.18.1)
      guard-minitest (2.3.1)
        guard (~> 2.0)
        minitest (>= 3.0)
      heroku-deflater (0.6.2)
        rack (>= 1.4.5)
      high_voltage (2.4.0)
      i18n (0.7.0)
      jbuilder (2.5.0)
        activesupport (>= 3.0.0, < 5.1)
        multi_json (~> 1.2)
      jquery-rails (4.1.1)
        rails-dom-testing (>= 1, < 3)
        railties (>= 4.2.0)
        thor (>= 0.14, < 2.0)
      jquery-turbolinks (2.1.0)
        railties (>= 3.1.0)
        turbolinks
      json (1.8.3)
      launchy (2.4.3)
        addressable (~> 2.3)
      letter_opener (1.4.1)
        launchy (~> 2.2)
      libv8 (3.16.14.15)
      listen (3.1.5)
        rb-fsevent (~> 0.9, >= 0.9.4)
        rb-inotify (~> 0.9, >= 0.9.7)
        ruby_dep (~> 1.2)
      loofah (2.0.3)
        nokogiri (>= 1.5.9)
      lumberjack (1.0.10)
      mail (2.6.4)
        mime-types (>= 1.16, < 4)
      method_source (0.8.2)
      mime-types (3.1)
        mime-types-data (~> 3.2015)
      mime-types-data (3.2016.0521)
      mini_backtrace (0.1.3)
        minitest (> 1.2.0)
        rails (>= 2.3.3)
      mini_portile2 (2.1.0)
      minitest (5.9.0)
      minitest-reporters (1.0.5)
        ansi
        builder
        minitest (>= 5.0)
        ruby-progressbar
      multi_json (1.12.1)
      nenv (0.3.0)
      nokogiri (1.6.8)
        mini_portile2 (~> 2.1.0)
        pkg-config (~> 1.1.7)
      notiffany (0.1.0)
        nenv (~> 0.1)
        shellany (~> 0.0)
      pg (0.17.1)
      pkg-config (1.1.7)
      pry (0.10.4)
        coderay (~> 1.1.0)
        method_source (~> 0.8.1)
        slop (~> 3.4)
      puma (2.11.1)
        rack (>= 1.1, < 2.0)
      rack (1.6.4)
      rack-test (0.6.3)
        rack (>= 1.0)
      rails (4.2.7)
        actionmailer (= 4.2.7)
        actionpack (= 4.2.7)
        actionview (= 4.2.7)
        activejob (= 4.2.7)
        activemodel (= 4.2.7)
        activerecord (= 4.2.7)
        activesupport (= 4.2.7)
        bundler (>= 1.3.0, < 2.0)
        railties (= 4.2.7)
        sprockets-rails
      rails-deprecated_sanitizer (1.0.3)
        activesupport (>= 4.2.0.alpha)
      rails-dom-testing (1.0.7)
        activesupport (>= 4.2.0.beta, < 5.0)
        nokogiri (~> 1.6.0)
        rails-deprecated_sanitizer (>= 1.0.1)
      rails-html-sanitizer (1.0.3)
        loofah (~> 2.0)
      rails_12factor (0.0.2)
        rails_serve_static_assets
        rails_stdout_logging
      rails_serve_static_assets (0.0.5)
      rails_stdout_logging (0.0.5)
      railties (4.2.7)
        actionpack (= 4.2.7)
        activesupport (= 4.2.7)
        rake (>= 0.8.7)
        thor (>= 0.18.1, < 2.0)
      rake (11.2.2)
      rb-fsevent (0.9.7)
      rb-inotify (0.9.7)
        ffi (>= 0.5.0)
      rdoc (4.2.2)
        json (~> 1.4)
      ref (2.0.0)
      ruby-progressbar (1.8.1)
      ruby_dep (1.3.1)
      sass (3.4.22)
      sass-rails (5.0.5)
        railties (>= 4.0.0, < 6)
        sass (~> 3.1)
        sprockets (>= 2.8, < 4.0)
        sprockets-rails (>= 2.0, < 4.0)
        tilt (>= 1.1, < 3)
      sdoc (0.4.0)
        json (~> 1.8)
        rdoc (~> 4.0, < 5.0)
      shellany (0.0.1)
      simple_form (3.2.1)
        actionpack (> 4, < 5.1)
        activemodel (> 4, < 5.1)
      slop (3.6.0)
      spring (1.7.2)
      sprockets (3.6.3)
        concurrent-ruby (~> 1.0)
        rack (> 1, < 3)
      sprockets-rails (3.1.1)
        actionpack (>= 4.0)
        activesupport (>= 4.0)
        sprockets (>= 3.0.0)
      sqlite3 (1.3.11)
      therubyracer (0.12.2)
        libv8 (~> 3.16.14.0)
        ref
      thor (0.19.1)
      thread_safe (0.3.5)
      tilt (2.0.5)
      turbolinks (5.0.0)
        turbolinks-source (~> 5)
      turbolinks-source (5.0.0)
      tzinfo (1.2.2)
        thread_safe (~> 0.1)
      uglifier (3.0.0)
        execjs (>= 0.3.0, < 3)
      web-console (3.3.0)
        activemodel (>= 4.2)
        debug_inspector
        railties (>= 4.2)

  PLATFORMS
    ruby

  DEPENDENCIES
    animate-rails
    better_errors
    bootstrap-sass (~> 3.3, >= 3.3.6)
    byebug
    coffee-rails
    font-awesome-rails
    guard-minitest (= 2.3.1)
    heroku-deflater
    high_voltage (~> 2.4.0)
    jbuilder
    jquery-rails
    jquery-turbolinks
    letter_opener
    mini_backtrace (= 0.1.3)
    minitest-reporters (= 1.0.5)
    pg (= 0.17.1)
    puma (= 2.11.1)
    rails
    rails_12factor (= 0.0.2)
    sass-rails (~> 5.0, >= 5.0.5)
    sdoc (= 0.4.0)
    simple_form
    spring
    sprockets-rails
    sqlite3
    therubyracer
    turbolinks
    uglifier (>= 1.3.0)
    web-console

  RUBY VERSION
     ruby 2.2.3p173

  BUNDLED WITH
     1.12.5

Upvotes: 2

Views: 1785

Answers (2)

Nick Read
Nick Read

Reputation: 7

Some times the pg gem can get you into trouble, try running this in your terminal bundle install --without production this will let you install the necessary gems but skip the group :production do where your pg gem is located.

This should let everything run much smoother.

If not try uninstalling the pg and rails_12factor gems:

$ bundle exec gem uninstall pg
$ bundle install --without production
$ bundle exec gem uninstall rails_12factor
$ bundle install --without production

I hope this helps!

Upvotes: 0

mycargus
mycargus

Reputation: 2618

Have you tried what the error message suggests?

ensure you can run $ bundle exec rake -P against your app and using the production group of your Gemfile.

I encountered a similar issue and trying this showed me I had a Rake task trying to load a dependency which was only defined in my :test Gemfile group.

Removing the require '<dependency>' statement from the Rake task solved the problem as it turned out the Rake task didn't need that library. Alternatively, I could have added the gem to my :production Gemfile group.

Point being this: Try what the error message suggests if you haven't already. :)

Upvotes: 1

Related Questions