问题描述
我是新来的rails和heroku
i尝试了以下代码将我的应用程序推送到heroku
rails new snippets
cd snippets
git init
git add。
git commit -m初始提交
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
heroku创建
git push heroku master
但我收到以下错误
安装sqlite3(1.3.10)时发生错误,而Bundler不能
remote:continue 。
remote:在捆绑之前确保`gem install sqlite3 -v'1.3.10'`成功。
remote:!
remote:!无法通过Bundler安装宝石。
remote:!
remote:!检测到Heroku不支持的sqlite3 gem。
remote:! https://devcenter.heroku.com/articles/sqlite3
remote:!
remote:
remote:!推送被拒绝,未能编译Ruby应用程序
remote:
remote:验证部署....
remote:
remote:!推拒绝强大的水域8202。
远程:
至https://git.heroku.com/powerful-waters-8202.git
! [remote rejected] master - > master(pre-receive hook refused)
错误:未能将一些文件推送到'https://git.heroku.com/powerful-waters-8202.git'
我将gemfile修改为::
组:devlopment:test do
gem'sqlite3'
end
group:production do
gem'pg'
end
code>
当我运行bundle install
i时,出现以下错误:
使用本机扩展安装pg 0.18.2
Gem :: Ext :: BuildError:错误:无法构建gem原生扩展。
/home/user/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150705-24664-1i1n8se.rb extconf.rb
检查pg_config .. 。yes
使用/ usr / bin / pg_config中的配置值
您需要安装postgresql-server-dev-XY来构建服务器端扩展,或者使用libpq-dev来构建客户端应用程序。
您需要安装postgresql-server-dev-X.Y来构建服务器端扩展,或者使用libpq-dev来构建客户端应用程序。
检查libpq-fe.h ... no
找不到'libpq-fe.h头文件
*** extconf.rb失败***
可能不是由于某种原因创建Makefile,可能缺少必要的
库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能
需要配置选项。
提供的配置选项:
--with-opt-dir
--without-opt-dir
--with-opt-include
- -without-opt-include = $ {opt-dir} / include
--with-opt-lib
--without-opt-lib = $ {opt-dir} / lib
--with-make-prog
--without-make-prog
--srcdir =。
--curdir
--ruby = / home / user / .rvm / rubies / ruby-2.2.1 / bin / $(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include = $ {pg-dir} / include
--with-pg-lib
--without-pg-lib = $ {pg-dir} / lib
extconf失败,退出代码1
Gem文件将保持安装在/home/user/.rvm/gems/ruby-2.2.1/gems/pg-0.18 .2供检查。
记录到/home/user/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/pg-0.18.2/gem_make.out
的结果发生错误安装pg(0.18.2),并且Bundler无法继续。
在捆绑之前确保`gem install pg -v'0.18.2'`成功。
我试过使用命令
gem install pg -v'0.18.2'
现在我获得以下错误:
错误:安装pg时出错:
错误:无法构建gem本机扩展。
这是我的database.yml文件
#SQLite版本3.x
#gem install sqlite3
#
#确保SQLite 3 gem在您的Gemfile中定义
#gem' sqlite3'
#
默认值:& default
适配器:sqlite3
池:5
超时值:5000
开发:
<<:* default
database:db / development.sqlite3
#警告:定义为test的数据库将被删除,
#从当你运行rake时你的开发数据库。
#不要将此db设置为与开发或生产相同。
test:
database:db / test.sqlite3
产品:
和我的gemfile
source'https://rubygems.org'
#捆绑边缘Rails改为:gem'rails',github :'rails / rails'
gem'rails','4.2.1'
#使用sqlite3作为Active Record的数据库
#gem'sqlite3'
#使用SCSS for样式表
gem'sass-rails','〜> 5.0'
#使用Uglifier作为JavaScript资产的压缩器
gem'uglifier','> = 1.3.0'
#使用CoffeeScript作为.coffee资产和视图
gem'咖啡栏','〜> 4.1.0'
#请参阅https://github.com/rails/execjs#readme获取更多支持的运行时
#gem'therubyracer',平台:: ruby
#使用jquery作为JavaScript库
gem'jquery-rails'
#Turbolinks使Web应用程序中的以下链接更快。阅读更多:https://github.com/rails/turbolinks
gem'turbolinks'
#轻松构建JSON API。阅读更多:https://github.com/rails/jbuilder
gem'jbuilder','〜> 2.0'
#bundle exec rake doc:rails在doc / api下生成API。
gem'sdoc','〜> 0.4.0',组::doc
#使用ActiveModel has_secure_password
#gem'bcrypt','〜> 3.1.7'
#使用Unicorn作为应用服务器
#gem'unicorn'
#使用Capistrano进行部署
#gem'capistrano- rails',group::development
####################################### ############################################
组:开发,:test do#<<<<< :development,not devlopment
gem'sqlite3'
end
group:production do
gem'pg'
end
############################################# #####################
group:development,:test do
#在代码中的任何地方调用'byebug'来停止执行并获得调试器控制台
gem'byebug'
#访问异常页面上的IRB控制台或使用<%= console%>在视图中
gem'web-console','〜> 2.0'
#Spring通过让应用程序在后台运行来加速开发。阅读更多:https://github.com/rails/spring
gem'spring'
end
任何人都可以帮我解决这个问题吗? 我给你的建议是在开发中使用与生产中相同的数据库,PostgreSQL 。有很多原因,这是一个好主意,你刚刚遇到了一个,部署头痛。
但是让我们假设你坚持使用不同的数据库类型。这行在你的gemfile中看起来很奇怪 - 不开发
#
#
########################################### ########################################
group:development,:test做#<<<<< :development,not devlopment
gem'sqlite3'
end
我想你应该尝试
#
#
###### ################################################## ###########################
group:development,:test do
gem'sqlite3'
结束
让我知道它是怎么回事。
I am new to rails and herokui tried the following code to push my app to heroku
rails new snippets cd snippets git init git add . git commit -m "initial commit" wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh heroku create git push heroku master
but i get the following error
An error occurred while installing sqlite3 (1.3.10), and Bundler cannot remote: continue. remote: Make sure that `gem install sqlite3 -v '1.3.10'` succeeds before bundling. remote: ! remote: ! Failed to install gems via Bundler. remote: ! remote: ! Detected sqlite3 gem which is not supported on Heroku. remote: ! https://devcenter.heroku.com/articles/sqlite3 remote: ! remote: remote: ! Push rejected, failed to compile Ruby app remote: remote: Verifying deploy.... remote: remote: ! Push rejected to powerful-waters-8202. remote: To https://git.heroku.com/powerful-waters-8202.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/powerful-waters-8202.git'
i modified my gemfile as::
group :devlopment, :test do gem 'sqlite3' end group :production do gem 'pg' end
when i run bundle installi get the following error
Installing pg 0.18.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. /home/user/.rvm/rubies/ruby-2.2.1/bin/ruby -r ./siteconf20150705-24664-1i1n8se.rb extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. checking for libpq-fe.h... no Can't find the 'libpq-fe.h header *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/user/.rvm/rubies/ruby-2.2.1/bin/$(RUBY_BASE_NAME) --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib extconf failed, exit code 1 Gem files will remain installed in /home/user/.rvm/gems/ruby-2.2.1/gems/pg-0.18.2 for inspection. Results logged to /home/user/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/pg-0.18.2/gem_make.out An error occurred while installing pg (0.18.2), and Bundler cannot continue. Make sure that `gem install pg -v '0.18.2'` succeeds before bundling.
i tried using the command
gem install pg -v '0.18.2'
and now i get the following error
ERROR: Error installing pg: ERROR: Failed to build gem native extension.
here's my database.yml file
# 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
and my gemfile
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.1' # Use sqlite3 as the database for Active Record #gem 'sqlite3' # 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.1.0' # 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 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' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development ################################################################################### group :development, :test do # <<<< :development, not devlopment gem 'sqlite3' end group :production do gem 'pg' end ################################################################## group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end
can anyone help me out with this issue??
解决方案You have some good advice here already, but I'll add what I don't see mentioned.
My advice to you is to use the same database in development as you do in production, PostgreSQL . There are a number of reasons this is a good idea and you have just come across one, deployment headaches.
But let's say you stick with the different database types. This line in your gemfile looks strange to me-- "not devlopment"
# # ################################################################################### group :development, :test do # <<<< :development, not devlopment gem 'sqlite3' end
I think you should try
# # ################################################################################### group :development, :test do gem 'sqlite3' end
Let me know how it goes.
这篇关于将rails应用程序部署到heroku时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!