我在Heroku上部署了一个非常简单的示例rails应用程序时遇到问题。这个应用程序使用数据库。
在使用sqlite3的本地(OSX)中没有问题,但我无法推送到Heroku,因为有些sqlite3丢失了引用。 p>
我已经把Gemfile放在了测试,开发和生产环境之间的区别:
#gem'sqlite3' group:development,:test do gem'sqlite3' end group:production do gem'pg'结束以及捆绑带问题:
bundle install --without production但是当我部署到Heroku:
git push heroku master我得到了一些对sqlite3的引用,并且得到一个错误。
我试过用我的OSX安装postgresql,在Gemfile上只包含gem'pg',但我也有对sqlite3的引用。
我应该怎么做?我在Heroku上需要一些额外的配置来使用postgre db?
这是我在git推送给heroku master时获得的常见错误:
git push heroku master 计数对象:87,完成。 使用多达2个线程的增量压缩。 压缩对象:100%(76/76),完成。 写作对象:100%(87/87),30.32 KiB,完成。 共计87(增量2),重用0(增量0) -----> Heroku接收推送 -----> Ruby / Rails应用程序检测到 ----->使用Bundler版本1.2.1安装依赖项正在运行:bundle install --without development:test --path vendor / bundle --binstubs bin / --deployment 从https:// rubygems中获取gem元数据。 org / ......... 从rubygems/获取gem元数据.. 安装rake(0.9.2.2)安装i18n(0.6.1 )安装multi_json(1.3.7)安装activesupport(3.2.8)安装构建器(3.0.4)安装activemodel(3.2.8)安装erubis(2.7.0)安装旅程(1.0.4)安装机架(1.4.1)安装机架高速缓存(1.2)安装机架测试(0.6。 2)安装远足(1.2.1)安装倾斜(1.3.3)安装链轮(2.1.3)安装actionpack(3.2.8)安装mime-types(1.19)安装polyglot(0.3.3)安装treeto p(1.4.12)安装邮件(2.4.4)安装actionmailer(3.2.8)安装arel(3.0.2)安装tzinfo(0.3.35) 安装activerecord(3.2.8)安装activeresource(3.2.8)安装coffee-script-source(1.4.0)安装execjs(1.4.0)安装coffee-script(2.2.0)安装rack-ssl(1.3.2)使用原生扩展安装json(1.7.5)安装rdoc(3.12)安装thor(0.16.0)安装railties(3.2.8)安装咖啡栏(3.2.2)安装jquery-rails(2.1.3)使用Bundler(1.2.1)安装rails(3.2.8)安装sass(3.2.2)安装sass-rails(3.2.5)安装sqlite3(1.3。 6)原生扩展 Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。 / usr / local / bin / ruby extconf.rb 检查sqlite3.h ...没有 sqlite3.h缺失。试试'port install sqlite3 + universal'或'yum install sqlite-devel'并检查你的共享库搜索路径(sqlite3共享库所在的位置)。 *** 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 = / usr / local / bin / ruby --with-sqlite3-dir --without-sqlite3-dir - -with-sqlite3-include --without-sqlite3-include = $ {sqlite3-dir} / include --with-sqlite3-lib --without-sqlite3-lib = $ {sqlite3-dir} / lib --enable-local --disable -local Gem文件将保留安装在/tmp/build_28i7zx40b8bao/vendor/bundle/ruby/1.9.1/宝石/ sqlite3-1.3.6进行检查。 记录到/tmp/build_28i7zx40b8bao/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out 的结果安装sqlite3时出错(1.3。 6)和Bundler无法继续。 确保在捆绑之前,gem install sqlite3 -v'1.3.6'`成功。 ! !无法通过Bundler安装宝石。 ! !检测到Heroku不支持的sqlite3 gem。 ! devcenter.heroku/articles/how-do-i-use-sqlite3-for-development ! ! Heroku推送被拒绝,未能编译Ruby / rails应用程序 到git@heroku:pure-reach-4621.git ! [remote rejected] master - > master(pre-receive hook refused)错误:无法将某些参考文献推送到'git@heroku:pure-reach-4621.git'解决方案
我解决了这个问题。这是一个糟糕的使用git。
我需要更新Gemfile和Gemfile.lock中的更改:首先编译:
$ bundle然后:
$ git add Gemfile $ git add Gemfile.lock $ git commit -m'添加pg适配器gem' $ git push heroku master现在Heroku更新OK
现在运行postgresql数据库:
$ heroku运行rake db:migrate再见!
I've got a problem deploying a very simple example rails app on Heroku. This app uses a db.
In local (OSX) with sqlite3 there is no problem, but I can't push to Heroku because some lost reference to sqlite3.
I've put on Gemfile the distinction between test, development and production environments:
#gem 'sqlite3' group :development, :test do gem 'sqlite3' end group :production do gem 'pg' endand bundle withou problem:
bundle install --without productionBut when i deploy to Heroku:
git push heroku masterI've got some reference to sqlite3 and get an error.
I've tryed with postgresql installed on my OSX, and bundle with only "gem 'pg'" on Gemfile, but i've got also the reference to sqlite3
What should I do? I need some extra config on Heroku to use a postgre db?
This is the common error I obtain when git push to heroku master:
git push heroku master Counting objects: 87, done. Delta compression using up to 2 threads. Compressing objects: 100% (76/76), done. Writing objects: 100% (87/87), 30.32 KiB, done. Total 87 (delta 2), reused 0 (delta 0) -----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.2.1 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment Fetching gem metadata from rubygems/......... Fetching gem metadata from rubygems/.. Installing rake (0.9.2.2) Installing i18n (0.6.1) Installing multi_json (1.3.7) Installing activesupport (3.2.8) Installing builder (3.0.4) Installing activemodel (3.2.8) Installing erubis (2.7.0) Installing journey (1.0.4) Installing rack (1.4.1) Installing rack-cache (1.2) Installing rack-test (0.6.2) Installing hike (1.2.1) Installing tilt (1.3.3) Installing sprockets (2.1.3) Installing actionpack (3.2.8) Installing mime-types (1.19) Installing polyglot (0.3.3) Installing treetop (1.4.12) Installing mail (2.4.4) Installing actionmailer (3.2.8) Installing arel (3.0.2) Installing tzinfo (0.3.35) Installing activerecord (3.2.8) Installing activeresource (3.2.8) Installing coffee-script-source (1.4.0) Installing execjs (1.4.0) Installing coffee-script (2.2.0) Installing rack-ssl (1.3.2) Installing json (1.7.5) with native extensions Installing rdoc (3.12) Installing thor (0.16.0) Installing railties (3.2.8) Installing coffee-rails (3.2.2) Installing jquery-rails (2.1.3) Using bundler (1.2.1) Installing rails (3.2.8) Installing sass (3.2.2) Installing sass-rails (3.2.5) Installing sqlite3 (1.3.6) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/bin/ruby extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite-devel' and check your shared library search path (the location where your sqlite3 shared library is located). *** 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=/usr/local/bin/ruby --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib --enable-local --disable-local Gem files will remain installed in /tmp/build_28i7zx40b8bao/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection. Results logged to /tmp/build_28i7zx40b8bao/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue. Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling. ! ! Failed to install gems via Bundler. ! ! Detected sqlite3 gem which is not supported on Heroku. ! devcenter.heroku/articles/how-do-i-use-sqlite3-for-development ! ! Heroku push rejected, failed to compile Ruby/rails app To git@heroku:pure-reaches-4621.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku:pure-reaches-4621.git'解决方案
I've resolved the problem. It was a bad use of git.
I needed to update the changes in Gemfile and Gemfile.lock:
First compile:
$ bundlethen:
$ git add Gemfile $ git add Gemfile.lock $ git commit -m 'Added pg adapter gem' $ git push heroku masterNow Heroku updates OK
And now run the postgresql database:
$ heroku run rake db:migrateBye!
更多推荐
Sqlite3参考部署简单的heroku Rails应用程序
发布评论