0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2+Ubuntu20.04へのRubyインストール

Last updated at Posted at 2021-01-06

個人的なメモ

必要なライブラリのインストール

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g zlib1g-dev imagemagick git
sudo apt-get install -y nodejs npm
sudo apt-get install -y sqlite3 libsqlite3-dev
sudo apt-get install -y libmariadb-dev
sudo apt-get install -y libmysqlclient-dev

yarnのインストール

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn -y

Rubyをインストール

git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
echo '[ -f "$HOME/.profile" ] && source "$HOME/.profile"' >> ~/.bash_profile
echo '[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"' >> ~/.bash_profile
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
~/.rbenv/bin/rbenv init
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

確認

rbenv -v

ruby-build をインストール

mkdir -p "$(rbenv root)"/plugins
git clone https://github.com/sstephenson/ruby-build.git "$(rbenv root)"/plugins/ruby-build

rubyをインストール

rbenv install -l
rbenv install 2.6.6

インストールしたrubyの確認

rbenv global 2.6.6
ruby -v

ドライブのマウント設定

sudo tee /etc/wsl.conf <<EOF >/dev/null
[automount]
options = "metadata"
EOF

echo 'export PATH="$(echo "$PATH" | sed -r -e '"'"'s;:/mnt/[^:]+;;g'"'"')"' >> ~/.bash_profile
source ~/.bash_profile

ただし、上記を行うと、VS CodeなどのPATHも変更されてしまう。。。

参考

WSL の Ubuntu コンソールで Insecure world writable dir... という警告が出る件
https://www.oiax.jp/books/insecure_world_writable_dir.html

設定を有効にする為にWindowsを再起動する

bundleのインストール

gem install bundle
0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?