版本管理器
本文檔包含資訊與提示,以協助 Ruby LSP 的 VS Code 擴充功能與您的 Ruby 版本管理器協同運作。
asdf
請確保您使用的是最新版本的 asdf:https://asdf-vm.com/manage/commands.html。如果 asdf
是透過 Homebrew 安裝的,您可能需要先執行 brew upgrade asdf
。
如果您使用 asdf
並且 VS Code 擴充功能無法啟動環境(如 此問題中所述),您可以使用 asdf update
將 asdf
更新至最新版本,然後重新啟動 VS Code 來解決此問題。
Chruby
請確保您使用的是最新版本的 chruby。
如果您使用 chruby
但專案根目錄中沒有 .ruby-version
檔案,您可以將 .ruby-version
新增至其父資料夾作為備用方案。
例如,如果 /projects/my_project
沒有 .ruby-version
,則 chruby
會改為讀取 /projects/.ruby-version
。
Mise
請確保 Mise 是最新版本:https://mise.jdx.dev/faq.html#mise-is-failing-or-not-working-right
RVM
請確保 RVM 是最新版本:https://rvm.dev.org.tw/rvm/upgrading
自訂啟用
如果您使用的是此擴充功能不支援的其他版本管理器,或者如果您是手動將 Ruby 可執行檔插入到 PATH 中,您可能需要定義自訂啟用,以便擴充功能可以找到正確的 Ruby。
對於這些情況,請將 rubyLsp.rubyVersionManager.identifier
設定為 "custom"
,然後將 rubyLsp.customRubyCommand
設定為將啟用正確 Ruby 版本或將 Ruby bin
資料夾新增到 PATH
的 Shell 命令。一些範例:
{
// Don't forget to set the manager to custom when using this option
"rubyLsp.rubyVersionManager": {
"identifier": "custom",
},
// Using a different version manager than the ones included by default
"rubyLsp.customRubyCommand": "my_custom_version_manager activate",
// Adding a custom Ruby bin folder to the PATH
"rubyLsp.customRubyCommand": "PATH=/path/to/ruby/bin:$PATH",
}