根據以下跟蹤,我已經“安裝”了捆綁程式和 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說我什至沒有安裝這些寶石。它們出現在我添加到我的 PATH 的 GEM_PATH 檔案夾中,但運行gem list --local時根本不會顯示這些程式。- 我似乎可以無限地安裝這些 jekyll 和 bundler,就好像它們一開始就沒有安裝一樣。
我已經在這個論壇上研究這個問題幾天了,但沒有找到解決方案。任何指標將不勝感激。謝謝!
uj5u.com熱心網友回復:
我的建議是確保您的 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 二進制檔案。您可以使用typebash 命令以某種方式了解什么在哪里。在我的例子中:
[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 ~]#
在我的情況下它是有效的,但如果你希望使用不同的 Ruby 二進制檔案/usr/bin/ruby,它可能不正確。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/422145.html
標籤:
下一篇:HTML標簽的驗證問題
