10
7

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 5 years have passed since last update.

rbenv に新しいバージョンの Ruby をインストールする

Posted at

rbenv に新しいバージョンの Ruby をインストールする

Git でインストールした rbenv を Ruby 2.6.4 -> 2.6.5 へアップデートする手順

環境

  • Ubuntu 18.04

rbenv をアップデートする

$ cd ~/.rbenv
$ git pull origin master
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/rbenv/rbenv
 * branch            master     -> FETCH_HEAD
   4e92322..577f046  master     -> origin/master
Updating 4e92322..577f046
Fast-forward
 README.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

ruby-build をアップデートする

$ cd ~/.rbenv/plugins/ruby-build
$ git pull origin master
remote: Enumerating objects: 60, done.
remote: Counting objects: 100% (60/60), done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 60 (delta 29), reused 39 (delta 16), pack-reused 0
Unpacking objects: 100% (60/60), done.
From https://github.com/rbenv/ruby-build

- branch master -> FETCH_HEAD
  5db61ac..da8e0b4 master -> origin/master
  Updating 5db61ac..da8e0b4
  Fast-forward
  bin/ruby-build | 4 ++--
  share/ruby-build/2.4.8 | 2 ++
  share/ruby-build/2.4.9 | 2 ++
  share/ruby-build/2.5.7 | 2 ++
  share/ruby-build/2.6.5 | 2 ++
  share/ruby-build/truffleruby-19.2.0.1 | 7 +++++++
  6 files changed, 17 insertions(+), 2 deletions(-)
  create mode 100644 share/ruby-build/2.4.8
  create mode 100644 share/ruby-build/2.4.9
  create mode 100644 share/ruby-build/2.5.7
  create mode 100644 share/ruby-build/2.6.5
  create mode 100644 share/ruby-build/truffleruby-19.2.0.1

Ruby 2.6.5 をインストールする

$ rbenv install 2.6.5
Downloading ruby-2.6.5.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
Installing ruby-2.6.5...
Installed ruby-2.6.5 to /home/glorydays/.rbenv/versions/2.6.5

Ruby 2.6.5 をデフォルトにする

$ rbenv global 2.6.5
$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]

コマンドの確認

試しに Rails のプロジェクトを作成する。

$ rails new test-app
rbenv: rails: command not found

The `rails' command exists in these Ruby versions: 2.6.4

Ruby 2.6.5 に Rails はインストールされていないためインストールする。

rbenv exec gem install rails

rbenv で管理された Ruby に gem install する場合は rbenv exec で実行する。

rbenv exec gem install

bundler をインストールする。

$ rbenv exec gem install bundler
Fetching bundler-2.0.2.gem
Successfully installed bundler-2.0.2
1 gem installed

rails をインストールする。

$ rbenv exec gem install rails
Fetching thread_safe-0.3.6.gem
Fetching tzinfo-1.2.5.gem
$ rbenv rehash

コマンドの確認(再)

再度 Rails のプロジェクトを作成する。

$ rails new test-app
create
 create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
(省略)
Done in 8.56s.
Webpacker successfully installed 🎉 🍰

完了

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?