【问题标题】:Gem is not available after bundle install捆绑安装后 Gem 不可用
【发布时间】:2013-08-22 11:24:38
【问题描述】:

我有一个 Gemfile,我可以在其中添加一个新的 gem

gem 'activerecord-oracle_enhanced-adapter', git: "https://github.com/rsim/oracle-enhanced.git", branch: "rails4"

当我运行 bundle install 时,我得到了

> bundle install
Updating https://github.com/rsim/oracle-enhanced.git
Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
...
Using activerecord (4.0.0)
Using activerecord-oracle_enhanced-adapter (1.4.2) from https://github.com/rsim/oracle-enhanced.git (at rails4) 
Using bundler (1.3.5)
...

但是当我打电话给gem list 时,宝石不见了。如果我尝试在 irb 中加载这个 gem,我会得到

irb
require 'rubygems'
=> false
gem 'activerecord'
=> true
gem 'activerecord-oracle_enhanced-adapter'
Gem::LoadError: Could not find 'activerecord-oracle_enhanced-adapter' (>= 0) among 49 total gem(s)

我不明白这种行为。我以这种方式将几个 gem 添加到我的 Gemfile 中,并且它们都在工作。

我的测试系统:

  • RVM
  • 红宝石 2.0.0p195
  • 新宝石组
  • 新的 rails 4 项目除了 Gemfile 中的这个 gem 没有任何修改
  • 我尝试了两个不同的用户
  • Ubuntu 12.04

如果我调用 gem install activerecord-oracle_enhanced-adapter,这个 gem 已安装,但不是来自“rails4”分支,我想使用 Gemfile

【问题讨论】:

    标签: ruby-on-rails gem bundle ruby-on-rails-4 gemfile


    【解决方案1】:

    尝试调用bundle exec irb,这样您将在特定的 Gemset 范围而不是系统一中加载 irb。

    【讨论】:

    • 谢谢。我仍然不知道,为什么这个 gem 没有使用 gem list 列出(所有其他的),但是 bundle exec gem list 显示了这个 gem。 bundle exec irb 也可以。
    • 也许该链接会对您有所帮助,一般来说,bundle exec 在当前 Gemset 范围内运行命令:stackoverflow.com/questions/6588674/…
    猜你喜欢
    • 1970-01-01
    • 2013-09-02
    • 2017-10-26
    • 1970-01-01
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-01
    相关资源
    最近更新 更多