参考資料
- ただし、2020.5.17時点ではバージョンを上げないとエラー発生。
仮想環境
# ボックス一覧を見る $ vagrant box list # CentOSのボックスでVagrantfileを作成 $ vagrant init bento/centos-7.5 # プロビジョニング $ vagrant up
[root@localhost ~] # yum install git
yum install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel
## リポジトリをクローン $ git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv # <-※1 ## /etc/profileファイルに、RBENVのルートパスを追記 $ echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile # <-※2 ## /etc/profileファイルに、PATHを追記 $ echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile ## /etc/profileファイルに、 $ echo 'eval "$(rbenv init -)"' >> /etc/profile
$ rbenv --version
$ git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build
[余談]
sqlite3周りのエラー
[root@localhost ~]# gem install sqlite3 -v '1.4.2' --source 'https://rubygems.org/' Fetching sqlite3-1.4.2.gem Building native extensions. This could take a while... ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. current directory: /usr/local/rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sqlite3-1.4.2/ext/sqlite3 /usr/local/rbenv/versions/2.5.0/bin/ruby -I /usr/local/rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0 -r ./siteconf20200517-23570-mhv9mq.rb extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'brew install sqlite3', 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev' and check your shared library search path (the location where your sqlite3 shared library is located).
解決方法
[root@localhost ~]# yum install sqlite-devel これで、bundle install --path=~/sample/vendor/bundleが通った。
古いバージョンのRubyをインストールしようとすると、WARNING
[root@localhost ~]# rbenv install 2.4.4 Downloading ruby-2.4.4.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.4.tar.bz2 Installing ruby-2.4.4...
WARNING: ruby-2.4.4 is past its end of life and is now unsupported. It no longer receives bug fixes or critical security updates.