在我正在使用的本地機器上rbenv
當我跑步時,bundle install我得到:
The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Following files may not be writable, so sudo is needed:
/Library/Ruby/Gems/2.6.0
/Library/Ruby/Gems/2.6.0/build_info
/Library/Ruby/Gems/2.6.0/cache
/Library/Ruby/Gems/2.6.0/doc
/Library/Ruby/Gems/2.6.0/extensions
/Library/Ruby/Gems/2.6.0/gems
/Library/Ruby/Gems/2.6.0/specifications
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5
問題是,當我運行 rbenv 版本時,我得到了正確的版本(2.5.5):
system
* 2.5.5 (set by /Users/Mahmoud/dev-reps/non-docker/normal/.ruby-version)
當我運行時which ruby,它正確指向 rbenv:
/Users/Mahmoud/.rbenv/shims/ruby
甚至ruby -v給出正確的版本:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin21]
所以大概,2.5.5 是我唯一的版本。除此之外,我還嘗試了所有與 bundler 相關的常用技巧:
bundle uninstall,gem uninstall bundler -v 1.17.2
但似乎沒有任何效果。
我認為另一個“有趣”的事實給出了一個提示:which bundle給出:
/usr/local/bin/bundle
我的問題是這個 2.6.8 來自哪里?我該如何解決這個問題并啟動服務器?
uj5u.com熱心網友回復:
終于讓它作業了。
因此,問題的關鍵以及解決方案的關鍵在于which bundle:
/usr/local/bin/bundle
而紅寶石給了:
/Users/Mahmoud/.rbenv/shims/ruby
表明該捆綁包沒有使用來自 rbenv 的 ruby??。
我已經設定了路徑~/.bash_profile:
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
但顯然這還不夠,因為我使用的是 zsh。還必須添加相同的 2 行~/.zshrc并重新啟動終端。現在捆綁安裝按預期作業。
更新后~/.zshrc which bundle給出:
/Users/Mahmoud/.rbenv/shims/bundle
表明問題只是那個包使用了錯誤的紅寶石。
因此,如果您遇到此問題,只需通過添加上面指示的 2 行來確保~/.bash_profile并~/.zshrc擁有正確的路徑。重新啟動終端并檢查它現在是否作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/440716.html
上一篇:當我嘗試使用twilio-rubygem“警告:LoadError:cannotloadsuchfile--rack/media_type”時出現以下錯誤
下一篇:Ruby注入菊花鏈?
