Hol*_*lly 3 rubygems bundler ruby-on-rails-3 railstutorial.org
我正在关注Michael Hartl Ruby on Rails 教程,并且有一部分是他指示您更新 Gemfile 以包括:
group :production do
gem 'pg', '0.12.2'
end
Run Code Online (Sandbox Code Playgroud)
然后在终端中输入以下命令:
bundle update
bundle install --without production
Run Code Online (Sandbox Code Playgroud)
当您运行 bundle update 命令时,它会抛出以下错误。
sample_app:$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.3)
Using i18n (0.6.4)
etc
[omitted lines for brevity]
etc
Using railties (3.2.12)
Using coffee-rails (3.2.2)
Installing diff-lcs (1.1.3)
Using jquery-rails (2.0.2)
Installing pg (0.12.2)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/home/ross/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
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
etc
[omitted lines for brevity]
etc
Gem files will remain installed in /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2 for inspection.
Results logged to /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2/ext/gem_make.out
An error occurred while installing pg (0.12.2), and Bundler cannot
continue.
Make sure that `gem install pg -v '0.12.2'` succeeds before bundling.
sample_app:$
Run Code Online (Sandbox Code Playgroud)
通过'pg', '0.12.2'从Gemfile 中删除gem并在运行bundle update命令后替换它,我能够轻松克服此错误。这似乎工作正常,因为在后者'pg', '0.12.2'的without production标志中也省略了gem bundle install --without production。
该'pg', '0.12.2'只需要宝石与正确的数据库和一切工作部署到Heroku的罚款,甚至当我部署它的Heroku,但我只是想知道或者如果这是在教程的错误我失去了更大的东西吗?
每次运行都必须删除这个Gem也很烦人bundle update,bundle update真的有必要吗?
提前致谢
我正在遵循相同的教程,我认为在update不修改现有依赖项的情况下运行是多余的,但在这种情况下,它甚至会导致问题,因为updatecommand 没有--without参数。
我偶然发现了Rails 3 备忘单,它以这种方式提到了 bundler 工作流程:
从 Gemfile 添加或删除依赖项后
$ bundle- 提交 Gemfile 和 Gemfile.lock
修改现有依赖版本后
$ bundle update- 提交 Gemfile 和 Gemfile.lock

我读手册页的bundle update,并试图建议的工作流程其中包括运行bundle update之后bundle install。
在我的情况下(省略了一些输出):
$ bundle install --without production
Resolving dependencies...
Using rake (10.0.3)
...
Installing rspec-core (2.11.1)
Your bundle is complete!
Gems in the group production were not installed. <-- check
$ bundle update
Resolving dependencies...
Using rake (10.0.3)
...
Using uglifier (1.2.3)
Your bundle is updated!
Gems in the group production were not installed. <-- check
Run Code Online (Sandbox Code Playgroud)
我用新的 RVM gem set 试了一下,一切都安装正确。
之后Gemfile.lock包含pg (0.12.2)并部署到 Heroku 工作。
推荐的工作流程
通常,在使用由 bundler 管理的应用程序时,您应该使用以下工作流程:
第一次创建 Gemfile 后,运行
$ bundle install将生成的 Gemfile.lock 签入版本控制
$ git add Gemfile.lock在另一台开发机器上签出此存储库时,运行
$ bundle install在部署机器上签出此存储库时,运行
$ bundle install --deployment更改 Gemfile 以反映新的或更新的依赖项后,运行
$ bundle install确保将更新的 Gemfile.lock 签入版本控制
$ git add Gemfile.lock如果 bundle install 报告冲突,请手动更新您在 Gemfile 中更改的特定 gem
$ bundle update rails thin如果要将所有 gem 更新为仍与 Gemfile 中列出的 gem 匹配的最新版本,请运行
$ bundle update
| 归档时间: |
|
| 查看次数: |
9434 次 |
| 最近记录: |