[英]Heroku push fails “Precompiling assets failed”
Ruby version: 2.0.0p195 Rails: 4.2.0beta4 Ruby版本:2.0.0p195 Rails:4.2.0beta4
So I tried to run rake assets:precompile. 因此,我尝试运行rake asset:precompile。 (Sounded like a good idea) And I get the following trace: (听起来不错)我得到以下跟踪:
rake aborted!
LoadError: cannot load such file -- sqlite3/database
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.10-x86-mingw32/
lib/sqlite3.rb:9:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.10-x86-mingw32/
lib/sqlite3.rb:9:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:72:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:72:in `block (2 levels) in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:70:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:70:in `block in require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:59:in `each'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/r
untime.rb:59:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.r
b:132:in `require'
C:/2/heroku2/config/application.rb:7:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:4
5:in `require'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:4
5:in `require'
C:/2/heroku2/Rakefile:4:in `<top (required)>'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_m
odule.rb:28:in `load'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/rake_m
odule.rb:28:in `load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:689:in `raw_load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:94:in `block in load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:93:in `load_rakefile'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:77:in `block in run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:176:in `standard_exception_handling'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/lib/rake/applic
ation.rb:75:in `run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in
`<top (required)>'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `load'
C:/RailsInstaller/Ruby2.0.0/bin/rake:23:in `<main>'
My gemfile: 我的gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
group :production do
gem 'pg'
gem 'rails_12factor'
end
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'pry'
gem 'sqlite3', '1.3.10'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
gem 'arel', '6.0.0.beta2'
gem 'devise'
gem 'paperclip', '~> 4.1'
gem 'seems_rateable'
I'm learning Ruby on Rails so please assume that I am missing the obvious. 我正在学习Ruby on Rails,因此请假设我缺少明显的东西。
EDIT: 编辑:
you're right trueinViso - I did not specify postgres in database.yml. 您是对的trueinViso-我没有在database.yml中指定postgres。 What should I write? 我应该写什么? This is database.yml: 这是database.yml:
# 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:
<<: *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
database: db/production.sqlite3
What I did: I changed the development database to use postgres 'pg'gem. 我做了什么:我将开发数据库更改为使用postgres'pg'gem。 (Which is probably not useful. I actually don't know if it is relevant). (这可能没有用。我实际上不知道它是否相关)。
Most importantly, after doing the above, I changed database.yml to (the adapter was wrong "postgresl": 最重要的是,完成上述操作后,我将database.yml更改为(适配器错误的“ postgresl”:
development:
adapter: postgresql
host: localhost
database: pqqq
username: pqqqq
password: pqqqq
test:
adapter: postgresql
encoding: unicode
database: testdb_pow
pool: 5
username: parseb
password: testtt
Than I ran rake asstes:precompile and afterwards git push heroku master and it worked. 比我跑了耙asstes:precompile,然后git push heroku master,它起作用了。 (Do not forget to migrate the database on heroku - heroku run db:migrate.) (不要忘记在heroku上迁移数据库-heroku运行db:migrate。)
You didn't need run rake assets:precompile
. 您不需要运行rake assets:precompile
。
Just go to config/production.rb
and set serve_static_assets = true
. 只需转到config/production.rb
并设置serve_static_assets = true
。
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = true
When you push to heroku again, the assets will work. 当您再次按下heroku时,资产将起作用。 That was the solution to me. 那是我的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.