Homebrew install Ruby keg-only can't find gem [英] Homebrew install Ruby keg-only can't find gem

查看:15
本文介绍了Homebrew install Ruby keg-only can't find gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用 Homebrew 安装 Ruby 后让 irb 工作?

How do I get irb to work after installing Ruby with Homebrew?

当我尝试运行 irb 时,出现错误:

When I try to run irb, I get an error:

$ irb
Traceback (most recent call last):
    2: from /usr/local/opt/ruby/bin/irb:23:in `<main>'
    1: from /usr/local/lib/ruby/site_ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
/usr/local/lib/ruby/site_ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem irb (>= 0.a) with executable irb (Gem::GemNotFoundException)

我试过了:

$ brew link ruby
Warning: Refusing to link macOS-provided software: ruby
If you need to have ruby first in your PATH run:
  echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

For compilers to find ruby you may need to set:
  export LDFLAGS="-L/usr/local/opt/ruby/lib"
  export CPPFLAGS="-I/usr/local/opt/ruby/include"

我的 /etc/paths 文件顶部有以下几行:

I have the lines below at the top of my /etc/paths file:

/usr/local/bin
/usr/local/opt/ruby/bin
/usr/local/lib/ruby/gems/2.6.0/bin

irb 没有出现在 gem list 的输出中,但是:

irb doesn't show up in the output of gem list, but:

$ find /usr/local -name irb
/usr/local/lib/ruby/2.6.0/irb
/usr/local/Cellar/ruby/2.6.0_1/bin/irb
/usr/local/Cellar/ruby/2.6.0_1/lib/ruby/2.6.0/irb
/usr/local/Cellar/ruby/2.6.0_1/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb
/usr/local/Cellar/ruby/2.6.0_1/share/ri/2.6.0/system/lib/irb

我也遇到了与 ri & 类似的问题rdoc.

I'm also having a similar issue with ri & rdoc.

推荐答案

运行:gem install irb 你现在可以开始了.

Run: gem install irb and you now good to go.

这篇关于Homebrew install Ruby keg-only can't find gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆