【问题标题】:Gem is installed but it is not found by bundle showGem 已安装,但 bundle show 找不到
【发布时间】:2023-03-21 21:23:01
【问题描述】:

我无法让 pg gem 与我的 rails 应用程序一起使用。

当我执行 sudo bundle install 时,我得到:

Using rake (10.0.4)
Using i18n (0.6.4)
Using multi_json (1.7.2)
Using activesupport (3.2.8)
Using builder (3.0.4)
Using activemodel (3.2.8)
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.1)
Using tilt (1.3.6)
Using sprockets (2.1.3)
Using actionpack (3.2.8)
Using mime-types (1.22)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.8)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.8)
Using activeresource (3.2.8)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.8)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Using pg (0.15.0)
Using bundler (1.1.5)
Using rails (3.2.8)
Using sass (3.2.7)
Using sass-rails (3.2.6)
Using uglifier (1.3.0)

但是,当我为任何宝石做“捆绑秀”时,我得到:

Could not find pg-0.15.0 in any of the sources

另外,当我执行任何 rake 命令时,我得到:

/usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/spec_set.rb:90:in `block in materialize': Could not find pg-0.15.0 in any of the sources (Bundler::GemNotFound)
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83:in `map!'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/spec_set.rb:83:in `materialize'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/definition.rb:127:in `specs'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/bundler-1.1.5/lib/bundler/environment.rb:27:in `specs'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rubygems-bundler-1.0.6/lib/rubygems-bundler/noexec.rb:41:in `candidate?'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rubygems-bundler-1.0.6/lib/rubygems-bundler/noexec.rb:60:in `setup'
        from /usr/local/rvm/gems/ruby-1.9.3-p194@global/gems/rubygems-bundler-1.0.6/lib/rubygems-bundler/noexec.rb:75:in `<top (required)>'
        from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:60:in `rescue in require'
        from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:9:in `<main>'

我怀疑这与 RVM 以及自从我最近更改为 1.9.3 以来我使用的 Ruby 版本有关。有什么想法吗?

【问题讨论】:

  • 您使用的是基于用户的 rvm 还是普通 rvm?还是没有 rvm?
  • 我不知道基于用户的 RVM 和普通 RVM 有什么区别。但是,是的,我正在使用 RVM。
  • 基于用户的 RVM => ruby​​ 和所有 gem 都安装在名为 .rvm 的主目录中。但在常见的 rvm ruby​​ 和安装在 /usr/local/rvm 中的所有 gem 中,它可能因系统而异。
  • 请检查您的主目录中是否有 .rvm 文件夹?
  • 升级到 1.9.3 后是否更新了 ruby​​gems 并重新安装了 bundler 前几天我遇到了类似的问题,不得不重新安装 ruby​​gems 和 bundler

标签: ruby-on-rails ruby gem rvm


【解决方案1】:

试试bundle install 不带sudo

【讨论】:

  • 安装 pg 时失败:Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension。 /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 检查 pg_config... 是 使用来自 /usr/bin/pg_config 的配置值检查 libpq-fe.h...是检查 libpq/libpq-fs.h... 是检查 pg_config_manual.h... 是检查 -lpq 中的 PQconnectdb()... 不检查 -llibpq 中的 PQconnectdb()... 不检查 PQconnectdb () in -lms/libpq... no 找不到 PostgreSQL 客户端库 (libpq) 另外,我已经检查以确保已安装 libpq。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-08-03
  • 2011-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多