英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论