【问题标题】:Gem installed from github sources not shown in `gem list`从 github 源安装的 Gem 未显示在“gem 列表”中
【发布时间】:2016-01-19 12:34:20
【问题描述】:

我尝试从 github 源安装一些 gem,它已成功安装,但之后它没有显示在 gem list 输出中并且不能被要求。

我的 gem 在私人仓库中,但我可以在随机的公共仓库中重现这些步骤。 例如:

  1. 我创建 Gemfile 的内容:
source 'http://rubygems.org'
gem 'http_parser.rb', git: 'https://github.com/tmm1/http_parser.rb.git'
  1. 我打电话给bundle install,它的输出是:
Fetching https://github.com/tmm1/http_parser.rb.git
Fetching gem metadata from http://rubygems.org/.........
Fetching version metadata from http://rubygems.org/..
Resolving dependencies...
Using http_parser.rb 0.6.0 from https://github.com/tmm1/http_parser.rb.git (at master@10dd2ed)
Using bundler 1.11.2
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
  1. 之后,我打电话给gem list | grep http,却一无所获。我也不能在我的代码中调用require "http/parser",它找不到。

我做错了什么?

【问题讨论】:

  • 试试bundle exec gem list(或bundle list)。在您的代码中,您可能必须先调用require 'rubygems'require 'bundler/setup',然后才能调用require 'http/parser'。详情请见bundler.io/bundler_setup.html

标签: ruby git github rubygems


【解决方案1】:

谢谢@stefan,
require 'bundler/setup' 解决了我的问题

【讨论】:

    【解决方案2】:

    或者你可以使用 irb 来运行

    bundle exec irb
    

    而不是

    irb
    

    【讨论】:

      猜你喜欢
      • 2011-02-04
      • 2016-07-15
      • 1970-01-01
      • 2011-02-18
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多