🐷

Rubyの開発環境をアップデートした時のメモ

2021/01/17に公開

久しぶりにRubyを触りたくなったので、個人環境のRubyをアップデートする。

最新版のRubyをインストールする

rbenvのアップデート

rbenvはanyenv経由でインストールしてあるのでanyenv-updateが使える。
anyenv-updateについてはこちらを参照。
https://github.com/znz/anyenv-update

$ anyenv update                                                         
Skipping 'anyenv'; not git repo
Updating 'anyenv/anyenv-update'...
Updating 'rbenv'...
Updating 'rbenv/ruby-build'...
Updating 'anyenv manifest directory'...

Rubyのインストール

現時点での最新版は3.0.0になる。

$ rbenv install --list
2.5.8
2.6.6
2.7.2
3.0.0
jruby-9.2.14.0
mruby-2.1.2
rbx-5.0
truffleruby-20.3.0
truffleruby+graalvm-20.3.0

Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all / -L' to show all local versions.

3.0.0をインストールする。

 $ rbenv install 3.0.0
Downloading ruby-3.0.0.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz
Installing ruby-3.0.0...
Installed ruby-3.0.0 to /home/tmaeda/.anyenv/envs/rbenv/versions/3.0.0

インストールした3.0.0を使うように変更する。

 $ rbenv global 3.0.0                                                     
 $ ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

VSCode用の設定を確認

VSCodeのlintで使うgemをインストールしなおす

$ gem install reek rubocop solargraph ruby-debug-ide debase --no-document
Fetching kwalify-0.7.2.gem
Fetching rainbow-3.0.0.gem
Fetching reek-6.0.3.gem
Fetching parser-3.0.0.0.gem
Fetching ast-2.4.1.gem
Successfully installed rainbow-3.0.0
Successfully installed ast-2.4.1
Successfully installed parser-3.0.0.0
Successfully installed kwalify-0.7.2
Successfully installed reek-6.0.3
Fetching ruby-progressbar-1.11.0.gem
Fetching unicode-display_width-2.0.0.gem
Fetching parallel-1.20.1.gem
Fetching rexml-3.2.4.gem
Fetching rubocop-ast-1.4.0.gem
Fetching rubocop-1.8.1.gem
Fetching regexp_parser-2.0.3.gem
Successfully installed unicode-display_width-2.0.0
Successfully installed ruby-progressbar-1.11.0
Successfully installed rubocop-ast-1.4.0
Successfully installed rexml-3.2.4
Successfully installed regexp_parser-2.0.3
Successfully installed parallel-1.20.1
Successfully installed rubocop-1.8.1
Fetching yard-0.9.26.gem
Fetching tilt-2.0.10.gem
Fetching nokogiri-1.11.1-x86_64-linux.gem
Fetching reverse_markdown-2.0.0.gem
Fetching rubocop-1.7.0.gem
Fetching unicode-display_width-1.7.0.gem
Fetching thor-1.0.1.gem
Fetching parser-2.7.2.0.gem
Fetching kramdown-2.3.0.gem
Fetching kramdown-parser-gfm-1.1.0.gem
Fetching jaro_winkler-1.5.4.gem
Fetching e2mmap-0.1.0.gem
Fetching backport-1.1.2.gem
Fetching solargraph-0.40.1.gem
Successfully installed yard-0.9.26
Successfully installed tilt-2.0.10
Successfully installed thor-1.0.1
Successfully installed unicode-display_width-1.7.0
Successfully installed parser-2.7.2.0
Successfully installed rubocop-1.7.0
Successfully installed nokogiri-1.11.1-x86_64-linux
Successfully installed reverse_markdown-2.0.0
Successfully installed kramdown-2.3.0
Successfully installed kramdown-parser-gfm-1.1.0
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.4
Successfully installed e2mmap-0.1.0
Successfully installed backport-1.1.2
Successfully installed solargraph-0.40.1
Fetching rake-13.0.3.gem
Fetching ruby-debug-ide-0.7.2.gem
Successfully installed rake-13.0.3
Building native extensions. This could take a while...
Successfully installed ruby-debug-ide-0.7.2
Building native extensions. This could take a while...
Successfully installed debase-0.2.4.1
29 gems installed

VSCode拡張のrubyの設定も変わっているらしかったので、settings.json修正。
古い設定はこちらを参照。
https://github.com/rubyide/vscode-ruby/blob/master/docs/legacy.md

    ...省略
    "ruby.lint": {
        "rubocop": true,
        "reek": true
    },
    "ruby.format": "rubocop",
    ...省略

おわり

とりあえずlinterとdebuggerの動作が出来ることを確認して終わり。

Discussion