ruby-on-rails - 使用 Rails 推送到 Heroku 时出错 - sh : 2: Syntax error: Unterminated quoted string

标签 ruby-on-rails ruby heroku push

我正在使用 Rails 并尝试将我的应用程序推送到 Heroku。我以前制作过各种应用程序,但从未遇到过这个问题。我花了几个小时寻找问题的原因,但无法弄清楚。我已经运行了 bundle install、bundle update、删除了 Heroku .env 变量,但没有任何帮助。

当我运行 git push heroku master 时,出现以下错误:

    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'

这是我的 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

在 localhost 上一切正常,但无法推送到 heroku。如果您还需要什么,请告诉我。任何帮助都会非常感谢!!

如问题中所述,它可能与 .bundle/config 有关。我删除了没有改变任何东西的东西,我从 bundle config 的输出是:

        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"

这也是我要求的 Gemfile.lock:(请注意我必须删除一小部分不重要的 heroku 推送错误消息,因为我已经使用了最大堆栈溢出正文字符数)

  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

最佳答案

您是否尝试过错误消息所提示的内容?

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

我遇到了类似的问题,尝试这表明我有一个 Rake 任务试图加载一个只在我的 :test 中定义的依赖项。 gem 文件组。

删除 require '<dependency>' Rake 任务中的语句解决了问题,因为事实证明 Rake 任务不需要该库。或者,我可以将 gem 添加到我的 :production Gemfile 组。

要点是:如果您还没有尝试过错误消息的建议,请尝试。 :)

关于ruby-on-rails - 使用 Rails 推送到 Heroku 时出错 - sh : 2: Syntax error: Unterminated quoted string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38339093/

相关文章:

ruby-on-rails - Rails CookieStore::CookieOverflow,不适用于所有用户,仅在生产中

git - 在 Heroku 上编辑 settings.xml 文件

heroku 上的 Java Web 应用程序空白页面但在本地运行

spring - Heroku 应用程序拒绝启动,因为它无法加载 kotlin.jvm.internal.Intrinsics

ruby-on-rails - rails 4 -- 连接 collection_select 中的字段

javascript - 我的 masonry 图像仅显示在一个列中

ruby-on-rails - Rails 事件记录验证 - 我应该验证非用户生成的数据吗

ruby-on-rails - 迁移成功时,rails 迁移没有反射(reflect)

ruby - 如何在纯 Ruby(无 Rails)中为 IE8 使用 Capybara?

ruby - 如何获得元素中最常见的类