[英]cannot install ruby using rvm as an unprivileged user with no sudo privileges
根據 rvm 文檔
https://rvm.io/rvm/install
應該可以作為非特權用戶安裝 rvm,然后安裝 ruby。
在故障排除中
https://rvm.io/support/troubleshooting
它指出:
rvm 組中的任何用戶都可以更新 RVM、rubies 和 gemset。 安裝后沒有理由使用 sudo。
rvm 作為非特權用戶安裝良好(沒有 rvm 組):
nosudo-user@my-site.com:~$ bash ~/downloads/rvm_installer.sh stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
...
Installing RVM to /<user-home>/.rvm/
...
但是,當我嘗試安裝 ruby 版本時,嘗試執行 apt-get 失敗(我認為)因為它需要 sudo 權限:
nosudo-user@my-site.com:~$ rvm install 2.6.6
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.6.tar.bz2
...
Updating system... password required for 'apt-get --quiet --yes update':
.
Error running 'requirements_debian_update_system ruby-2.6.6',
please read /<user-home>/.rvm/log/1659735568_ruby-2.6.6/update_system.log
Requirements installation failed with status: 1.
從日志:
2022-08-05 21:39:28] requirements_debian_update_system
requirements_debian_update_system ()
{
__rvm_try_sudo apt-get --quiet --yes update || {
\typeset __ret=$?;
case ${__ret} in
100)
rvm_error "There has been an error while updating your system using \`apt-get\`.
It seems that there are some 404 Not Found errors for repositories listed in:
/etc/apt/sources.list
/etc/apt/sources.list.d/*.list
apt-get update(作為具有 sudo 權限的用戶)顯示沒有錯誤。
應該如何安裝 rvm 以便非特權用戶可以安裝 ruby 版本?
Casper 的上述回答提供了缺失的信息; 缺少一些庫。 但是,能夠以非特權用戶身份安裝所需的步驟相當不直觀(至少對我而言):
使用 sudo 安裝 rvm; 在該過程中,它創建了“rvm”組。
將所需用戶添加到 rvm 組 注意:在此步驟之后嘗試以非特權用戶身份安裝 ruby 仍然失敗。
sudo to root 獲取為 root 安裝的 rvm 魔術路徑,然后開始安裝 ruby,但在要求安裝完成后終止該進程。
以所需的非特權用戶身份登錄並使用 rvm 為該用戶安裝所需的 ruby。
命令:
sudo rvm_installer.sh stable
sudo usermod -a -G rvm the-user
sudo -i
rvm install 2.6.6
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.6.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
Updating system..
Installing required packages: g++, gcc, autoconf, automake, bison, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, libyaml-dev, make, pkg-config, sqlite3, libgmp-dev, libreadline-dev......................|
Requirements installation successful.
^C
exit
sudo -i -u the-user
rvm install 2.6.6
我的猜測是您的系統缺少一些用於從源代碼構建 Ruby 的基本系統庫。 因此,RVM 會嘗試為您獲取構建庫。 這將是一次性更新,在您的系統安裝了正確的庫后,RVM 將不再需要sudo
。
但是,如果您願意,可以使用以下命令完全禁用 apt 更新:
rvm autolibs disable
請注意,如果您缺少構建要求,那么 Ruby 的構建步驟很可能會失敗。 找出答案的唯一方法是嘗試。
在這種情況下,您可以使用requirements
命令來幫助您安裝缺少的依賴項:
rvm requirements
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.