Pushing to Heroku failed after adding new gems for postgresql and installing bundle
当尝试推送到heroku master时,在安装了postgresql所需的gem之后,因为heroku无法识别sqlite3,它无法预编译资产并编译应用程序。我正在按照此在线指南将其部署到heroku:http://jgtr.github.io/blog/2013/07/28/deploying-a-sqlite3-database-to-heroku-for-production-using-postgres/
有什么问题吗?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | git push heroku master Counting objects: 2287, done. Delta compression USING up TO 4 threads. Compressing objects: 100% (1951/1951), done. Writing objects: 100% (2287/2287), 17.77 MiB | 17.00 KiB/s, done. Total 2287 (delta 534), reused 0 (delta 0) remote: Compressing SOURCE files... done. remote: Building SOURCE: remote: remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.2.1 remote: -----> Installing dependencies using bundler 1.9.7 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment 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: USING rake 10.4.2 remote: Installing minitest 5.8.3 remote: Installing i18n 0.7.0 remote: Installing thread_safe 0.3.5 remote: Installing builder 3.2.2 remote: Installing mini_portile2 2.0.0 remote: Installing erubis 2.7.0 remote: Installing rack 1.6.4 remote: Installing mime-types 2.99 remote: Installing json 1.8.3 remote: Installing arel 6.0.3 remote: Installing addressable 2.3.8 remote: Installing execjs 2.6.0 remote: Installing thor 0.19.1 remote: Installing sass 3.4.19 remote: Installing coffee-script-SOURCE 1.10.0 remote: Installing multipart-post 2.0.0 remote: Installing concurrent-ruby 1.0.0 remote: Installing hashie 3.4.3 remote: Installing high_voltage 2.4.0 remote: Installing multi_json 1.11.2 remote: Installing jwt 1.5.2 remote: USING bundler 1.9.7 remote: Installing multi_xml 0.5.5 remote: Installing tilt 2.0.1 remote: Installing tzinfo 1.2.2 remote: Installing rack-test 0.6.3 remote: Installing mail 2.6.3 remote: Installing autoprefixer-rails 6.1.2 remote: Installing uglifier 2.7.2 remote: Installing select2-rails 4.0.0 remote: Installing coffee-script 2.4.1 remote: Installing faraday 0.9.2 remote: Installing sprockets 3.5.0 remote: Installing omniauth 1.2.2 remote: Installing activesupport 4.2.1 remote: Installing bootstrap-sass 3.3.6 remote: Installing koala 2.2.0 remote: Installing oauth2 1.0.0 remote: Installing pg 0.18.4 remote: Installing rails-deprecated_sanitizer 1.0.3 remote: Installing globalid 0.3.6 remote: Installing activemodel 4.2.1 remote: Installing jbuilder 2.3.2 remote: Installing omniauth-oauth2 1.4.0 remote: Installing activejob 4.2.1 remote: Installing activerecord-postgresql-adapter 0.0.1 remote: Installing omniauth-facebook 3.0.0 remote: Installing activerecord 4.2.1 remote: Installing nokogiri 1.6.7 remote: Installing loofah 2.0.3 remote: Installing rails-dom-testing 1.0.7 remote: Installing rails-html-sanitizer 1.0.2 remote: Installing actionview 4.2.1 remote: Installing actionpack 4.2.1 remote: Installing sprockets-rails 2.3.3 remote: Installing actionmailer 4.2.1 remote: Installing railties 4.2.1 remote: Installing bootstrap-datepicker-rails 1.5.0 remote: Installing simple_form 3.2.0 remote: Installing bootstrap-generators 3.3.4 remote: Installing bootstrap-typeahead-rails 0.10.5.1 remote: Installing chart-js-rails 0.0.9 remote: Installing coffee-rails 4.1.0 remote: Installing jquery-rails 4.0.5 remote: Installing rails 4.2.1 remote: Installing sass-rails 5.0.4 remote: Bundle complete! 27 Gemfile dependencies, 67 gems now installed. remote: Gems IN the groups development AND test were NOT installed. remote: Bundled gems are installed INTO ./vendor/bundle. remote: Bundle completed (26.34s) remote: Cleaning up the bundler cache. remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: NoMethodError: undefined method `configure' for main:Object remote: /tmp/build_1a115f32b847c2bee80ca9efb3688741/config/environment.rb:7:in `<top (required)>' remote: /tmp/build_1a115f32b847c2bee80ca9efb3688741/vendor/bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:328:in `require' remote: /tmp/build_1a115f32b847c2bee80ca9efb3688741/vendor/bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:328:IN `require_environment!' remote: /tmp/build_1a115f32b847c2bee80ca9efb3688741/vendor/bundle/ruby/2.2.0/gems/railties-4.2.1/lib/rails/application.rb:457:in `block IN run_tasks_blocks' remote: /tmp/build_1a115f32b847c2bee80ca9efb3688741/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define' remote: Tasks: TOP => environment remote: (See FULL trace BY running task WITH --trace) remote: ! remote: ! Precompiling assets failed. remote: ! remote: remote: ! Push rejected, failed TO compile Ruby app remote: remote: Verifying deploy.... remote: remote: ! Push rejected TO nokorupsi. remote: TO https://git.heroku.com/nokorupsi.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed TO push SOME refs TO 'https://git.heroku.com/nokorupsi.git' |
这是Gemfile(我之前已经通过捆绑安装更新了Gemfile.lock,所以应该正确安装所有gem):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | SOURCE 'https://rubygems.org' ruby '2.2.1' gem 'rails', '4.2.1' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'jbuilder', '~> 2.0' GROUP :development, :test do gem 'byebug' gem 'web-console', '~> 2.0' gem 'spring' END gem 'bootstrap-sass' gem 'high_voltage' gem 'omniauth' gem 'omniauth-facebook' gem 'simple_form' GROUP :development do gem 'better_errors' gem 'hub', :require=>nil gem 'quiet_assets' gem 'rails_layout' gem 'sqlite3' END GROUP :production do gem 'pg' gem"activerecord-postgresql-adapter" END gem 'koala' gem 'bootstrap-generators', '~> 3.3.4' gem"select2-rails" gem 'bootstrap-typeahead-rails' gem 'bootstrap-datepicker-rails' gem 'chart-js-rails' |
这是配置目录中的database.yml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem IS defined IN your Gemfile # gem 'sqlite3' # DEFAULT: &DEFAULT # adapter: sqlite3 # pool: 5 # timeout: 5000 development: adapter: sqlite3 DATABASE: DATABASE.db # <<: *DEFAULT # DATABASE: db/development.sqlite3 # Warning: The DATABASE defined AS"test" will be erased AND # re-generated FROM your development DATABASE WHEN you run"rake". # Do NOT SET this db TO the same AS development OR production. test: adapter: sqlite3 DATABASE: DATABASE.db # <<: *DEFAULT # DATABASE: db/test.sqlite3 production: adapter: postgresql DATABASE: nokorupsi username: username password: password host: localhost # <<: *DEFAULT # DATABASE: db/production.sqlite3 |
这是配置目录中的application.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed IN Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module MerdekaHack class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run"rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central TIME (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true end end |
这是配置目录中的environment.rb:
1 2 3 4 5 | # LOAD the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize! |
这是config目录中环境文件夹中的development.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | Rails.application.configure do # Settings specified here will take precedence OVER those IN config/application.rb. # IN the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have TO restart the web server WHEN you make code changes. config.cache_classes = FALSE # Do NOT eager LOAD code ON boot. config.eager_load = FALSE # SHOW FULL error reports AND disable caching. config.consider_all_requests_local = TRUE config.action_controller.perform_caching = FALSE # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = FALSE # Print deprecation notices TO the Rails logger. config.active_support.deprecation = :log # Raise an error ON page LOAD IF there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation AND preprocessing OF assets. # This OPTION may cause significant delays IN VIEW rendering WITH a LARGE # NUMBER OF complex assets. config.assets.debug = TRUE # Asset digests allow you TO SET far-future HTTP expiration dates ON ALL assets, # yet still be able TO expire them through the digest params. config.assets.digest = TRUE # Adds additional error checking WHEN serving assets at runtime. # Checks FOR improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = TRUE # Raises error FOR missing translations # config.action_view.raise_on_missing_translations = TRUE # DATABASE FOR development SET :DATABASE,"sqlite3:///database.db" END |
这是config目录中相同环境文件夹中的production.rb:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | Rails.application.configure do # Settings specified here will take precedence OVER those IN config/application.rb. # Code IS NOT reloaded BETWEEN requests. config.cache_classes = TRUE # Eager LOAD code ON boot. This eager loads most OF Rails AND # your application IN memory, allowing BOTH threaded web servers # AND those relying ON copy ON WRITE TO perform better. # Rake tasks automatically IGNORE this OPTION FOR performance. config.eager_load = TRUE # FULL error reports are disabled AND caching IS turned ON. config.consider_all_requests_local = FALSE config.action_controller.perform_caching = TRUE # Enable Rack::Cache TO put a simple HTTP cache IN front OF your application # ADD `rack-cache` TO your Gemfile BEFORE enabling this. # FOR large-scale production USE, consider USING a caching reverse proxy LIKE # NGINX, varnish OR squid. # config.action_dispatch.rack_cache = TRUE # Disable serving static files FROM the `/public` folder BY DEFAULT since # Apache OR NGINX already handles this. config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts AND CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do NOT fallback TO assets pipeline IF a precompiled asset IS missed. config.assets.compile = FALSE # Asset digests allow you TO SET far-future HTTP expiration dates ON ALL assets, # yet still be able TO expire them through the digest params. config.assets.digest = TRUE # `config.assets.precompile` AND `config.assets.version` have moved TO config/initializers/assets.rb # Specifies the header that your server uses FOR sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # FOR Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # FOR NGINX # Force ALL access TO the app OVER SSL, USE Strict-Transport-Security, AND USE secure cookies. # config.force_ssl = TRUE # USE the lowest log level TO ensure availability OF diagnostic information # WHEN problems arise. config.log_level = :debug # Prepend ALL log LINES WITH the following tags. # config.log_tags = [ :subdomain, :uuid ] # USE a different logger FOR distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # USE a different cache store IN production. # config.cache_store = :mem_cache_store # Enable serving OF images, stylesheets, AND JavaScripts FROM an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # IGNORE bad email addresses AND do NOT raise email delivery errors. # SET this TO TRUE AND configure the email server FOR immediate delivery TO raise delivery errors. # config.action_mailer.raise_delivery_errors = FALSE # Enable locale fallbacks FOR I18n (makes lookups FOR any locale fall back TO # the I18n.default_locale WHEN a translation cannot be found). config.i18n.fallbacks = TRUE # Send deprecation notices TO registered listeners. config.active_support.deprecation = :notify # USE DEFAULT logging formatter so that PID AND TIMESTAMP are NOT suppressed. config.log_formatter = ::Logger::Formatter.new # Do NOT dump schema after migrations. config.active_record.dump_schema_after_migration = FALSE # Connecting TO postgresql db = URI.parse(ENV['postgres://iqwljiwwoqdysd:qzGRGgasKi_sMysSP4dcabR8Km@ec2-54-83-61-45.compute-1.amazonaws.com:5432/dde6roet07bko1'] || 'postgres://localhost/mydb') ActiveRecord::Base.establish_connection( :adapter => db.scheme == 'postgres' ? 'postgresql' : db.scheme, :host => db.host, :username => db.user, :password => db.password, :DATABASE => db.path[1..-1], :encoding => 'utf8' ) END |
删除:
ruby" activerecord-postgresql-适配器"
从生产开始,然后重试。