rbenvを使います
Ubuntu 18.02で試しました
Readmeの記載通りにインストール
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ cd ~/.rbenv && src/configure && make -C srcUbuntuを使っているので、.bashrcに追記
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrcrbenv-doctorでrbenvをチェックする
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash$ cd ~/.rbenv
$ git pullrbenv installを使うためにはruby-buildが必要
rbenv/ruby-build: Compile and install Ruby
$ mkdir -p "$(rbenv root)"/plugins
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build$ cd "$(rbenv root)"/plugins/ruby-build && git pull$ rbenv install -l
$ rbenv install 2.6.0システム全体で使うRuby versionの指定
$ rbenv global 2.6.0バージョンアップ
$ gem update --systemgem管理に
Bundler: The best way to manage a Ruby application's gems
を使います
$ gem install bundler初期化
$ bundle initGemfileに書かれたgemをインストール
--path をつけると指定したところへインストール
つけないとシステムへインストール
bundle install --path vendor/bundle一度 --path をつけると記憶され2回目からは指定いらない
実行
bundle exec をつけないとシステムのgemを実行する
bundle exec rails -v