rbenv: 动态扩展 $PATH 以便包含 gem 可执行文件

huangapple go评论50阅读模式
英文:

rbenv: dynamically extend $PATH for gem binaries

问题

我已经安装了 rbenv,并且它可以正常工作:

$ rbenv local
3.2.0
$ ruby --version
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]

我安装了 rufo gem 用于格式化我的代码,这也正常工作:

$ gem install rufo

似乎 rbenv 知道 rufo 的二进制文件位置:

$ rbenv which rufo
/home/patrick/.rbenv/versions/3.2.0/bin/rufo

但它在我的 $PATH 中找不到:

$ which rufo
which: no rufo in (…)

我可以像这样运行它来格式化我的文件 hello.rb

$ `rbenv which rufo` hello.rb
$ echo $?
0

但我希望可以直接这样调用它:

$ rufo hello.rb

我需要进行哪些配置?

英文:

I got rbenv installed, and it works fine:

$ rbenv local
3.2.0
$ ruby --version
ruby 3.2.0 (2022-12-25 revision a528908271) [x86_64-linux]

I installed the gem rufo to format my code, which worked fine:

$ gem install rufo

It seems that rbenv is aware of the binary location of rufo:

$ rbenv which rufo
/home/patrick/.rbenv/versions/3.2.0/bin/rufo

However, it cannot be found in my $PATH:

$ which rufo
which: no rufo in (…)

I can run it as follows to format my file hello.rb:

$ `rbenv which rufo` hello.rb
$ echo $?
0

However, I'd like to call it directly as follows:

$ rufo hello.rb

What do I need to configure?

答案1

得分: 0

运行 rbenv rehash 更新 shims:

$ which rufo 
which: no rufo in (…)

$ rbenv rehash
$ which rufo
/home/patrick/.rbenv/shims/rufo
英文:

Run rbenv rehash to update the shims:

$ which rufo 
which: no rufo in (…)

$ rbenv rehash
$ which rufo
/home/patrick/.rbenv/shims/rufo 

huangapple
  • 本文由 发表于 2023年2月6日 05:00:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/75355477.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定