簡體   English   中英

無法在 Ubuntu 上安裝 Ruby

[英]Unable to install Ruby on Ubuntu

我正在嘗試在 Ubuntu 上安裝 Ruby 2.6.1,但一直遇到此錯誤。

已嘗試卸載 Ubuntu,谷歌搜索問題,以管理員模式運行,下載不同的版本。

這是錯誤:

:~$ rvm install 2.6.1
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.1.tar.bz2
Checking requirements for ubuntu.
Installing requirements for ubuntu.
mkdir: cannot create directory ‘/usr/share/rvm/log/1625135668_ruby-2.6.1’: Permission denied
tee: /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log: No such file or directory
Updating system..jaydene password required for 'apt-get --quiet --yes update':
Sorry, try again.
jaydene password required for 'apt-get --quiet --yes update':
..
Error running 'requirements_debian_update_system ruby-2.6.1',
please read /usr/share/rvm/log/1625135668_ruby-2.6.1/update_system.log
Requirements installation failed with status: 1.
:~$

您可以使用 gorails 網站來檢查 ruby​​ on rails 安裝。 並且 ruby​​ 根據系統上的依賴項安裝版本。 如果它不是創建 2.6.1,它將安裝下一個支持的版本,例如。 2.6.7. 檢查這個網站: https : //gorails.com/setup/ubuntu/21.04

檢查這個: How do I install Ruby 1.9.3 on Ubuntu without RVM? 但是 SO 說要避免鏈接答案所以這里是腳本:

#!/usr/bin/env bash
# -- this really is the only solution that worked for me on snap :/

ruby -v
if ! command -v ruby &> /dev/null
then
    echo "Going to try to install ruby (ideally 3.1.2)"
    # - install rebenv (following ruby-build really is needed eventhough it doesn't look like it)
    mkdir -p ~/.rbenv
    cd ~/.rbenv
    git clone https://github.com/rbenv/rbenv.git .
    # if $HOME/.rbenv/bin not in path append it, otherwise don't change it
    echo $PATH | tr ':' '\n' | awk '{print "  " $0}';
    if [[ ":$PATH:" != *":$HOME/.rbenv/bin:"* ]]; then
      echo "might want to put $HOME/.rbenv/bin in your path"
      export PATH="$HOME/.rbenv/bin:$PATH"
#      echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc.lfs
    fi
    eval "$(rbenv init -)"
    rbenv -v

    # - install ruby-build, odd, this really is needed for ruby to install despite it not looking like ruby build is need at the bottom
    mkdir -p ~/.ruby-build
    cd ~/.ruby-build
    git clone https://github.com/rbenv/ruby-build.git .
    # if $HOME/.ruby-build/bin not in path append it, otherwise don't change it
    echo $PATH | tr ':' '\n' | awk '{print "  " $0}';
    if [[ $PATH != *"$HOME/.ruby-build/bin"* ]]; then
      echo "might want to put $HOME/.ruby-build/bin in your path"
      export PATH="$HOME/.ruby-build/bin:$PATH"
#      echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bashrc.lfs
    fi
    ruby-build --version

    # - install ruby without sudo -- using rbenv
    mkdir -p ~/.local
    #    ruby-build 3.1.2 ~/.local/
    rbenv install 3.1.2
    rbenv global 3.1.2
fi
ruby -v

# - Original Prover doesn't work on SNAP
# Proverbot's way to install ruby
#    # First, install Ruby, as that is for some reason required to build the "system" project
#    git clone https://github.com/rbenv/ruby-build.git ~/ruby-build
#    mkdir -p ~/.local
#    PREFIX=~/.local ./ruby-build/install.sh
#    ~/.local/ruby-build 3.1.2 ~/.local/
# ref: https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby/1756372#1756372

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM