我第一次将Rails应用程序部署到heroku,但我无法正常工作。
我已按照此处的指示进行操作:
https://www.codecademy.com/articles/deploy-rails-to-heroku
remote: Bundle completed (206.01s)
remote: Cleaning up the bundler cache.
remote: -----> Installing node-v10.15.3-linux-x64
remote: -----> Installing yarn-v1.16.0
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: Rails couldn't infer whether you are using multiple databases from your database.yml and can't generate the tasks for the non-primary databases. If you'd like to use this feature, please simplify your ERB.
remote: rake aborted!
remote: YAML syntax error occurred while parsing /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): did not find expected key while parsing a block mapping at line 8 column 1
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:246:in `rescue in database_configuration'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:221:in `database_configuration'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:200:in `block (2 levels) in <class:Railtie>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `each'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:198:in `block in <class:Railtie>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `instance_exec'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `run'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:60:in `run_initializers'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:363:in `initialize!'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/zeitwerk-2.3.1/lib/zeitwerk/kernel.rb:34:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:339:in `require_environment!'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:523:in `block in run_tasks_blocks'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
remote:
remote: Caused by:
remote: Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 8 column 1
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:228:in `database_configuration'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:200:in `block (2 levels) in <class:Railtie>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `each'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:198:in `block in <class:Railtie>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `instance_exec'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `run'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:60:in `run_initializers'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:363:in `initialize!'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/zeitwerk-2.3.1/lib/zeitwerk/kernel.rb:34:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:339:in `require_environment!'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/railties-6.0.3.2/lib/rails/application.rb:523:in `block in run_tasks_blocks'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote: /tmp/build_75338afd2107b4ab61f0bd3f16d859f7/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
remote: Tasks: TOP => environment
remote: (See full trace by running task with --trace)
remote:
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to politiscale-01.
remote:
To https://git.heroku.com/politiscale-01.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/politiscale-01.git'
这也是我的gem文件中的相关内容:
gem 'sqlite3', group: :development
gem 'pg', '0.18.1', group: :production
还有我的datbase.yml文件:
# SQLite. Versions 3.8.0 and up are supported.
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: postgresql
encoding: unicode
# For details on connection pooling, see Rails configuration guide
# https://guides.rubyonrails.org/configuring.html#database-pooling
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
#default: &default
# adapter: sqlite3
# pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
# timeout: 5000
development:
<<: *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:
<<: *default
database: db/test.sqlite3
production:
<<: *default
adapter: postgresql
database: db/production.sqlite3
你想做你的事情,并告诉我我在做什么错吗?
答案 0 :(得分:0)
在您的database.yml文件中更改此行-
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
......
如果您这样保存Gemfile会更好-
group :development do
gem 'sqlite3'
end
group :test do
gem 'pg'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
并再次在heroku上部署