rake assets:precompile,rake aborted - 错误推送到heroku - ruby​​ on rails

时间:2018-01-30 20:43:17

标签: ruby-on-rails ruby heroku heroku-postgres

我一直在尝试将我的Ruby on Rails应用程序部署到Heroku,但一直遇到错误。非常感谢提前帮助!

我一直按照此链接中的说明部署我的应用:http://curriculum.railsbridge.org/intro-to-rails/deploying_to_heroku

我将我的gemfile更改为以下内容然后运行



bundle install --without production




宝石文件:



source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.3'

# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# 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', platform: :mri
  gem 'sqlite3'
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

gem 'bootstrap-sass', '~> 3.3.7'
gem 'devise', '~> 4.2'

gem 'toastr-rails', "~> 1.0"

gem 'omniauth', '~> 1.6'
gem 'omniauth-facebook', '~> 4.0'
gem 'paperclip', '~> 5.1.0'
gem 'geocoder', '~> 1.4'

gem 'jquery-ui-rails', '~> 5.0'
gem 'momentjs-rails', '~> 2.17'
&#13;
&#13;
&#13;

以下是Heroku的构建日志。它抱怨没有宝石&#39; pg&#39;在gemfile中,但我确实添加了它,也进行了bundle install。

&#13;
&#13;
Running: rake assets:precompile
       rake aborted!
       Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
&#13;
&#13;
&#13;

从heroku构建日志

&#13;
&#13;
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.3.4
###### WARNING:
       You have the `.bundle/config` file checked into your repository
       It contains local state like the location of the installed bundle
       as well as configured git local gems, and other settings that should
       not be shared between multiple checkouts of a single repo. Please
       remove the `.bundle/` folder from your repo and add it to your `.gitignore` file.
       https://devcenter.heroku.com/articles/bundler-configuration
-----> Installing dependencies using bundler 1.15.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.1). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
       <Fetching a ton of things.....>
       Bundle complete! 25 Gemfile dependencies, 82 gems now installed.
       Gems in the groups development, test and production were not installed.
       Bundled gems are installed into ./vendor/bundle.
       Post-install message from paperclip:
       ##################################################
       #  NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER       #
       ##################################################
       Paperclip is now compatible with aws-sdk >= 2.0.0.
       If you are using S3 storage, aws-sdk >= 2.0.0 requires you to make a few small
       changes:
       * You must set the `s3_region`
       * If you are explicitly setting permissions anywhere, such as in an initializer,
       note that the format of the permissions changed from using an underscore to
       using a hyphen. For example, `:public_read` needs to be changed to
       `public-read`.
       For a walkthrough of upgrading from 4 to 5 and aws-sdk >= 2.0 you can watch
       http://rubythursday.com/episodes/ruby-snack-27-upgrade-paperclip-and-aws-sdk-in-prep-for-rails-5
       Bundle completed (25.24s)
       Cleaning up the bundler cache.
-----> Installing node-v6.11.1-linux-x64
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
       /tmp/build_b5def35a67e05bc1af4c0bb3931868f9/vendor/bundle/ruby/2.3.0/gems/activerecord-5.0.6/lib/active_record/connection_adapters/connection_specification.rb:176:in `rescue in spec'
       
<more errors here>
       /tmp/build_b5def35a67e05bc1af4c0bb3931868f9/vendor/bundle/ruby/2.3.0/gems/rake-12.3.0/exe/rake:27:in `<top (required)>'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这可能不是您想要的答案,但是您应该避免使用if (input.split('-').length > 1) { //your code }else { input='$'+input; } 进行开发,然后切换到sqlite3进行生产,因为可移植性问题和一般的头痛问题。

我建议您按以下方式重新创建应用:

pg

在开发过程中,您总是想要考虑最终产品。如果你知道你要将它部署到Heroku,那么你知道你将需要PostgreSQL,或者如果你不知道,现在就可以了。

您始终希望您的开发环境尽可能地与您的生产环境相似。

相关问题