[英]Why are jekyll/bundler programs installing, but not appearing in gem list
根據以下跟蹤,我已經“安裝”了捆綁程序和 jekyll,沒有問題:
$ gem install jekyll bundler
Successfully installed unicode-display_width-1.8.0
Successfully installed terminal-table-2.0.0
Successfully installed safe_yaml-1.0.5
Successfully installed rouge-3.27.0
Successfully installed forwardable-extended-2.6.0
Successfully installed pathutil-0.16.2
Successfully installed mercenary-0.4.0
Successfully installed liquid-4.0.3
Successfully installed rexml-3.2.5
Successfully installed kramdown-2.3.1
Successfully installed kramdown-parser-gfm-1.1.0
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Successfully installed rb-inotify-0.10.1
Successfully installed rb-fsevent-0.11.0
Successfully installed listen-3.7.1
Successfully installed jekyll-watch-2.2.1
Building native extensions. This could take a while...
Successfully installed sassc-2.4.0
Successfully installed jekyll-sass-converter-2.1.0
Successfully installed concurrent-ruby-1.1.9
Successfully installed i18n-1.9.0
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.8.0
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Successfully installed em-websocket-0.5.3
Successfully installed colorator-1.1.0
Successfully installed public_suffix-4.0.6
Successfully installed addressable-2.8.0
Successfully installed jekyll-4.2.1
Successfully installed bundler-2.3.6
28 gems installed
但是運行bundle
或jekyll
返回了一個command not found
錯誤。 好的,沒問題,我運行gem env
來找到 GEM PATH 並將其添加到我的路徑中。 現在找到了bundle
和jekyll
,但它們都給出了以下類型的錯誤:
$ jekyll
/usr/lib/ruby/3.0.0/rubygems.rb:265:in `find_spec_for_exe': can't find gem jekyll (>= 0.a) with executable jekyll (Gem::GemNotFoundException)
from /usr/lib/ruby/3.0.0/rubygems.rb:284:in `activate_bin_path'
from /home/<user>/.local/share/gem/ruby/3.0.0/bin/jekyll:25:in `<main>'
$ bundle
/usr/lib/ruby/3.0.0/rubygems.rb:265:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
from /usr/lib/ruby/3.0.0/rubygems.rb:284:in `activate_bin_path'
from /home/<user>/.local/share/gem/ruby/3.0.0/bin/bundle:25:in `<main>'
我編輯了上面的代碼片段以刪除識別信息。 一些東西:
gem update --system
不起作用。 我明白了,Updating rubygems-update
Successfully installed rubygems-update-3.3.6
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory @ dir_chdir - /usr/lib/ruby/gems/3.0.0/gems/rubygems-update-3.3.6
gem uninstall jekyll
和gem uninstall bundler
說我什至沒有安裝這些 gem。 它們出現在我添加到我的 PATH 的 GEM_PATH 文件夾中,但是運行gem list --local
根本不會顯示這些程序。我已經在這個論壇上研究這個問題幾天了,但沒有找到解決方案。 任何指針將不勝感激。 謝謝!
我的建議是確保您的 GEM_PATH 包含您在 GEM_HOME 變量中設置的路徑。 我自己,我有那些一直有效的環境變量:
export GEM_BIN=/home/user/Code/bin
export GEM_PATH=/home/user/Code/.gem
export GEM_HOME=/home/user/Code/.gem
export PATH=/home/user/Code/bin:$PATH
這里需要注意的是,對於單用戶系統來說,這是一個很好的設置,其中每個 gem 安裝都是從用戶完成的,而不是 root。
此外,您的問題可能源於一個事實,即您通過 rvm 之類的工具安裝了多個版本的 Ruby,例如,您的gem
命令引用了錯誤的 Ruby 二進制文件。 您可以使用type
bash 命令以某種方式了解什么在哪里。 在我的例子中:
[user@localhost ~]# type ruby
ruby is /usr/bin/ruby
[user@localhost ~]# type gem
gem is hashed (/usr/bin/gem)
[user@localhost ~]# type bundler
bundler is /home/user/Code/bin/bundler
[user@localhost ~]# type jekyll
jekyll is /home/user/Code/bin/jekyll
[user@localhost ~]#
為確保這些二進制文件調用正確的 Ruby 二進制文件,請嘗試以下操作:
[user@localhost ~]# head -n1 /home/user/Code/bin/jekyll
#!/usr/bin/ruby
[user@localhost ~]# head -n1 /usr/bin/gem
#!/usr/bin/ruby
[user@localhost ~]#
在我的情況下它是有效的,但如果您希望使用與/usr/bin/ruby
不同的 Ruby 二進制文件,它可能不正確。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.