Heroku推送失败“预编译资产失败”

时间:2015-01-29 00:10:52

标签: ruby-on-rails ruby heroku

Ruby版本:2.0.0p195 Rails:4.2.0beta4

所以我尝试运行rake资产:预编译。 (听起来像一个好主意)我得到以下痕迹:

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>'

我的宝石文件:

    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'

我正在学习Ruby on Rails,所以请假设我错过了明显的东西。

编辑:

你是对的trueinViso - 我没有在database.yml中指定postgres。我该怎么写?这是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

2 个答案:

答案 0 :(得分:0)

我做了什么: 我改变了开发数据库以使用postgres'pg'gem。 (这可能没用。我实际上不知道它是否相关)。

最重要的是,在完成上述操作后,我将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

比我运行rake asstes:预编译,然后git push heroku master,它工作正常。 (不要忘记在heroku上迁移数据库 - heroku run db:migrate。)

答案 1 :(得分:-1)

您不需要运行rake assets:precompile

只需转到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

当您再次推送到heroku时,资产将起作用。 那是我的解决方案。