繁体   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