为什么 Bundle 忽略 "gem 'pg'"?

5

目前正在工作

不确定发生了什么事情。在 Linux 上构建了 gemfile.lock 并将其移动过来,但是有一些东西丢失了,运行 bundle install 后问题得到解决。


Bundle 忽略了我在 Gemfile 中包含 "pg" gem 的指定。通过 gem install pg 安装 pg 可以正常工作,并且在使用 gem list --local 时也能看到它的存在。

Gemfile:

source 'http://rubygems.org'

gem 'rails' 
gem 'pg'

bundle install (no pg):

Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.2)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.2)
Using tilt (1.3.7)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using json (1.7.7)
Using rack-ssl (1.3.3)
Using bundler (1.3.5)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using rails (3.2.13)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

bundle show pg:

Could not find gem 'pg'.
Did you mean pg?

gem list --local (pg exists):

*** LOCAL GEMS ***

actionmailer (3.2.13)
actionpack (3.2.13)
activemodel (3.2.13, 3.1.11)
activerecord (3.2.13)    
activeresource (3.2.13)
activesupport (3.2.13, 3.1.11)
arel (3.0.2)
bigdecimal (1.2.0)
builder (3.0.4)
bundler (1.3.5)
erubis (2.7.0)
hike (1.2.2)
i18n (0.6.4, 0.6.1)
io-console (0.4.2)
journey (1.0.4)
json (1.7.7)
mail (2.5.3)
mime-types (1.23)
minitest (4.3.2)
multi_json (1.7.2)
pg (0.15.1 x64-mingw32)
polyglot (0.3.3)
psych (2.0.0)
rack (1.4.5, 1.3.10)
rack-cache (1.2)
rack-mount (0.8.3)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13)
railties (3.2.13)
rake (10.0.4, 0.9.6)
rdoc (4.0.0, 3.12.2)
rubygems-update (2.0.3)
sprockets (2.2.2, 2.0.4)
test-unit (2.0.0.0)
thor (0.18.1)
tilt (1.3.7)
treetop (1.4.12)
tzinfo (0.3.37)

此外,如果我尝试运行rails srake db:create等命令,会得到以下信息:
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)

Tasks: TOP => db:create
(See full trace by running task with --trace)

使用:

Windows 7, 64-bit
Rails 3.2.13
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
Bundler version 1.3.5

你可以尝试运行 bundle update - fmendez
相同的结果。谢谢你的帮助。 - Grogian
你能发一下你的Gemfile.lock文件吗?另外,你是在尝试在Linux机器上使用Windows生成的锁定文件吗? - egor_hm
2
不确定为什么这个问题已经关闭了。我目前也遇到了同样的情况,bundler拒绝将PG gem添加到我的bundle中。我认为这不是一个狭窄的情况。 - John Judd
2个回答

4
尝试删除您的 "gemfile.lock" 文件,然后重新运行 bundle install 命令?

1
谢谢,我之前已经尝试过几次,刚刚又试了一遍以确保。但是并没有解决问题。 - Grogian
这对我来说就可以了。谢谢! - Sebastian Sastre
在我的Mac OS X Yoshemite上无法工作。 - Askar

1
尝试删除 Gemfile.lock 并运行 bundle check,以查看 Gemfile 中列出的依赖项是否由当前安装的 gem 满足。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接