Rocky Linux 8にrbenvをインストールする

2021年10月24日

1.gitをインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# sudo dnf install -y git
# git --version
git version 2.27.0
# sudo dnf install -y git # git --version git version 2.27.0
# sudo dnf install -y git
# git --version
git version 2.27.0

2.rbenvをインストール
2.1 rbenvのパッケージをcloneする

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/root/.rbenv'...
Resolving deltas: 100% (1852/1852), done.
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv Cloning into '/root/.rbenv'... 略 Resolving deltas: 100% (1852/1852), done.
# git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
Cloning into '/root/.rbenv'...
略
Resolving deltas: 100% (1852/1852), done.

注意:ここではrootディレクトリ配下にrbenvのパッケージをcloneする

2.2 パッケージのPATHを通す
# echo 'export PATH="/root/.rbenv/bin:$PATH"' >> ~/.bash_profile

2.3 rbenvの初期化を行う

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ~/.rbenv/bin/rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init - bash)"
# ~/.rbenv/bin/rbenv init # Load rbenv automatically by appending # the following to ~/.bash_profile: eval "$(rbenv init - bash)"
# ~/.rbenv/bin/rbenv init

# Load rbenv automatically by appending
# the following to ~/.bash_profile:

eval "$(rbenv init - bash)"

2.4 動作確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# echo 'eval "$(rbenv init -)"'>>~/.bash_profile
# exec $SHELL -l
# echo 'eval "$(rbenv init -)"'>>~/.bash_profile # exec $SHELL -l
# echo 'eval "$(rbenv init -)"'>>~/.bash_profile
# exec $SHELL -l

# type rbenv

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
rbenv は関数です
rbenv ()
{
local command;
command="${1:-}";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
rbenv は関数です rbenv () { local command; command="${1:-}"; if [ "$#" -gt 0 ]; then shift; fi; case "$command" in rehash | shell) eval "$(rbenv "sh-$command" "$@")" ;; *) command rbenv "$command" "$@" ;; esac }
rbenv は関数です
rbenv ()
{
    local command;
    command="${1:-}";
    if [ "$#" -gt 0 ]; then
        shift;
    fi;
    case "$command" in
        rehash | shell)
            eval "$(rbenv "sh-$command" "$@")"
        ;;
        *)
            command rbenv "$command" "$@"
        ;;
    esac
}

バージョンを確認
# rbenv -v
rbenv 1.2.0-1-g6cc7bff

3.ruby-buildをインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/root/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 11860, done.
Resolving deltas: 100% (7835/7835), done.
# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build Cloning into '/root/.rbenv/plugins/ruby-build'... remote: Enumerating objects: 11860, done. 略 Resolving deltas: 100% (7835/7835), done.
# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Cloning into '/root/.rbenv/plugins/ruby-build'...
remote: Enumerating objects: 11860, done.
略
Resolving deltas: 100% (7835/7835), done.

インストールの確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# ls ~/.rbenv/plugins/ruby-build/bin
rbenv-install rbenv-uninstall ruby-build
# ls ~/.rbenv/plugins/ruby-build/bin rbenv-install rbenv-uninstall ruby-build
# ls ~/.rbenv/plugins/ruby-build/bin
rbenv-install rbenv-uninstall ruby-build

 

Rocky Linux 8

Posted by arkgame