繁体   English   中英

耙资产:预编译,耙中止-推送到heroku时出错-Ruby on Rails

[英]rake assets:precompile, rake aborted - error pushing to heroku - ruby on rails

我一直在尝试将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' 

以下是Heroku的构建日志。 它抱怨在gemfile中没有gem'pg',但是我确实添加了它,并且也做了捆绑安装。

 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). 

从heroku建立日志

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

这可能不是您想要的答案,但是由于可移植性问题和一般的麻烦,您应该避免使用sqlite3进行开发,然后切换到pg进行生产。

我建议您以以下方式重新创建您的应用程序:

rails new name-of-app --database=postgresql

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM