LoginSignup
2
1

More than 1 year has passed since last update.

Debianシステム全体にrbenvを導入する

Last updated at Posted at 2020-03-01

Debianシステム全体にrbenvを導入する

概要

Windows10のWSL2上に構築したDebianにrbenvを導入したときのメモ。
インストールマニュアル通りの手順を行うと、ホームディレクトリ配下にRubyバイナリが配置される。しかし個人的にホームディレクトリMac-Windows間でクラウド同期しているので、バイナリをホーム配下に配置したくなかった。
そこで/usr/local/lib配下にrbenvをインストールした。

環境

  • OS: Debian(WSL2で構築)
  • Shell: zsh

手順

  • githubよりrbenvclone
sudo git clone https://github.com/rbenv/rbenv.git /usr/local/lib/rbenv
  • またgithubよりruby-buildclone
sudo git clone https://github.com/rbenv/ruby-build.git /usr/local/lib/rbenv/plugins/ruby-build
  • .zshrcに環境変数を設定する
.zshrc
export RBENV_ROOT=/usr/local/lib/rbenv
export PATH=${RBENV_ROOT}/bin:${PATH}
eval "$(rbenv init -)"
  • .zshrcを再読み込み

権限が無い旨のエラーが出るがここでは無視

source ~/.zshrc
  • Rubyをインストールする(執筆時点で最新の2.7.0の場合)
sudo -E /usr/local/lib/rbenv/bin/rbenv install -v 2.7.0

インストールが完了すると

Downloading ruby-2.7.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.0.tar.bz2
Installing ruby-2.7.0...
Installed ruby-2.7.0 to /usr/local/lib/rbenv/versions/2.7.0

しっかり/usr/local/lib配下にインストールされている

  • バージョン設定
 sudo -E /usr/local/lib/rbenv/bin/rbenv global 2.7.0
  • 初期化する
 sudo -E /usr/local/lib/rbenv/bin/rbenv rehash
2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1