2021 May 02.
2021 Apr. 17.
2021 Mar. 28.
2021 Feb. 07.
2020 Oct. 08.
2020 Sep. 22.
2019 Oct. 12.
2018 Sep. 15.
2018 Aug. 14.
2017 Mar. 12.
2017 Feb. 21.
rubyのインストール・利用に必要なパッケージインストール
(Ubuntu)
# apt update && apt install git build-essential libssl-dev libreadline-dev zlib1g-dev
(Arch系Manjaro Linux)
# pacman -S make m4 gcc patch ed pkg-config
システムワイドにrbenv・ruby・bundlerをインストール
rbenvをインストール
参考元
Debian 9上でrbenvをシステムワイドにインストールする - 発声練習
rbenvでsystem wideに入れるときに気をつけたいこと - Qiita
rbenvを使ってシステムワイドにrubyをインストールする方法 - Qiita
rbenvを /usr/local/rbenvにインストール
# git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv
/usr/local/rbenvのグループ設定・パーミッション設定
# chgrp -R staff /usr/local/rbenv # chmod -R g+rwxXs /usr/local/rbenv
プラグイン ruby-build rbenv-default-gems をインストール
# git clone https://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build # chgrp -R staff /usr/local/rbenv/plugins/ruby-build # chmod -R g+rwxs /usr/local/rbenv/plugins/ruby-build # git clone https://github.com/rbenv/rbenv-default-gems.git /usr/local/rbenv/plugins/rbenv-default-gems # chgrp -R staff /usr/local/rbenv/plugins/rbenv-default-gems # chmod -R g+rwxs /usr/local/rbenv/plugins/rbenv-default-gems
staffグループを作成し、ユーザーをstaffグループに追加する
# groupadd staff (ubunbuでは最初からstaffが存在しているので不要) # usermod -aG staff USER1 # usermod -aG staff USER2
/etc/profile.d/HOGE.shに環境変数を設定。
"rbenv init"実行前にRBENV_ROOTとPATHをexportしないとrbenvによるrubyのインストール先が/root/になってしまう
RBENV_ROOT=/usr/local/rbenv export RBENV_ROOT PATH="${RBENV_ROOT}/bin:${PATH}" export PATH eval "$(rbenv init --no-rehash -)"
PCを再起動してグループ設定を反映する
# reboot
各ユーザーのcrontabの環境変数設定にもecho出力の値を記述しておく
echo $RBENV_ROOT echo $PATH
rubyをインストール
rubyインストール時に自動インストールするgemを記述した/usr/local/rbenv/default-gemsファイルを作成
(/usr/local/rbenv/default-gems)
bundler pry rbenv-rehash
rbenvでrubyをインストール
# rbenv install --list
ここで rbenv: no such command `install' となったら
出典 https://ogatism.jp/rbenv_install
# /usr/local/rbenv/plugins/ruby-build/install.sh
適当なバージョンのrubyをインストールする
# rbenv install 2.6.6p146 # rbenv rehash
インストールしたrubyをglobalにする。
# rbenv global 2.6.6p146 # rbenv rehash
gemのバージョンを最新にする。
# rbenv exec gem update --system # rbenv rehash
ホームディレクトリに ~/.gemrc を作成する。
(.gemrc)
install: --no-document update: --no-document
Bundlerをインストール
# rbenv exec gem install bundler --no-document # rbenv rehash
自作ライブラリの置き場所設定
# mkdir -p /usr/local/lib/ruby/VERSION # vim /etc/profile.d/YOUR-PROFILE.sh RUBYLIB=/usr/local/lib/ruby/VERSION export RUBYLIB
RUBYLIB=/usr/local/lib/ruby/VERSION をcrontabにも記述しておく
ユーザ別にrbenv・ruby・bundlerをインストール
rbenvをインストール
$ cd $ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv $ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
~/.profile に記述
export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" $ source ~/.profile $ rbenv rehash
rubyをインストール
$ rbenv install --list $ rbenv install 2.0.0-p648 $ rbenv rehash $ rbenv versions $ rbenv global 2.0.0-p648
bundlerをインストール
$ rbenv exec gem install bundler $ rbenv rehash $ rbenv exec bundle config --global path 'vendor/bundle'
~/.bundle/config を作成する
BUNDLE_PATH: vendor/bundle
自作ライブラリの置き場所設定
$ mkdir ~/ruby/lib/VERSION $ vim ~/.profile RUBYLIB=${HOME}/ruby/lib/VERSION export RUBYLIB