rubyのインストール

rbenvのインストールから始めた

  • rbenvでバージョンを手軽に切り替えることを覚えていたため
  • jekyllがruby 3.0で動作しなかったような記憶があったため…最後に2016年8月頃だから、もう、動作するかも、と思った

rbenv+rubyでrubyが動作するまで

  1. qiita に記事その1を見つけた。
  2. … installはこと無く完了(とても時間がかかる3〜5分位の体感)したが、ruby -vでshellが ruby Not Found とエラーを起こす
  3. rbenvのドキュメントをよく読まなかったためだろう(最後までドキュメントを読まず)、また qiita 記事その2 の世話になる
    • .bash_profileはログインシェルで読み込まれる。このまま作業するにはログアウト/ログインしないとならない
    • ログアウト/ログインがめんどくさかったので export PATH = "~/.rbenv/shims:$PATH" とした
    • .bash_profileには $(rbenv init -) まで追記したので、後日、その成果が確認できる
  • qiita 記事その1
// 1.初期化設定
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
// 2.初期化設定の反映
$ source ~/.bash_profile
// 3.rbenvのインストール:
$ brew install rbenv ruby-build
// 4.インストール可能なRubyのバージョン一覧の表示
$ rbenv install -l
// 5.指定したRubyのバージョンをインストール
$ rbenv install 2.3.5
// 6.インストールしたRubyを使用可能な状態にする⇒shimsへの反映
$ rbenv rehash
  • qiita 記事その2
$ cd
$ vi ~/.bash_profile
export PATH="~/.rbenv/shims:/usr/local/bin:$PATH"
eval "$(rbenv init -)"
$ source ~/.bash_profile # 変更をPCに反映させる

jekyllの動作を確認する

ここまで実行してきたコマンドを並べておこう

 2031  export PATH="~/.rbenv/shims:$PATH"
 2032  ruby -v
 2033  gem -v
 2034  gem -V
 2035  gcc -v
 2036  gem install jekyll bundler
 2037  cd HW
 2038  bundle exec jekyll serve
 2039  bundle -v
 2040  ls
 2041  bundle update
 2042  bundle exec jekyll serve
 2043  ls blog
 2044  bundle install
 2045  bundle exec jekyll serve
 2046  bundle update github-pages
 2047  bundle exec jekyll serve
 2048  rbenv versions
 2049  rbenv install -l
 2050  rbenv install 2.7.4
 2051  rbenv which
 2052  rbenv which ruby
 2053  rbenv global 2.7.4
 2054  rbenv which ruby
 2055  ruby -v
 2056  bundle exec jekyll serve
 2057  bundler install
 2058  jekyll
 2059  bundle exec jekyll serve
 2060  ls
 2061  ls blog
 2062  ls
 2063  bundle exec jekyll serve
 2064  bundle exec jekyll serve blog
 2065  cd blog
 2066  bundle exec jekyll serve blog
 2067  history

2038 bundler exec jekyll server がエラーを起こす

案の定、rubyのバージョンが災いした…が、まずbundle installが必要だった

$ bundle exec jekyll serve
Could not find github-pages-171, jekyll-mermaid-1.0.0, memprof2-0.1.1, activesupport-4.2.9, github-pages-health-check-1.3.5, jekyll-3.6.2, jekyll-avatar-0.5.0, jekyll-coffeescript-1.0.2, jekyll-default-layout-0.1.4, jekyll-feed-0.9.2, jekyll-gist-1.4.1, jekyll-github-metadata-2.9.3, jekyll-mentions-1.2.0, jekyll-optional-front-matter-0.3.0, jekyll-paginate-1.1.0, jekyll-readme-index-0.2.0, jekyll-redirect-from-0.12.1, jekyll-relative-links-0.5.2, jekyll-remote-theme-0.2.3, jekyll-sass-converter-1.5.0, jekyll-seo-tag-2.3.0, jekyll-sitemap-1.1.1, jekyll-swiss-0.4.0, jekyll-theme-architect-0.1.0, jekyll-theme-cayman-0.1.0, jekyll-theme-dinky-0.1.0, jekyll-theme-hacker-0.1.0, jekyll-theme-leap-day-0.1.0, jekyll-theme-merlot-0.1.0, jekyll-theme-midnight-0.1.0, jekyll-theme-minimal-0.1.0, jekyll-theme-modernist-0.1.0, jekyll-theme-primer-0.5.2, jekyll-theme-slate-0.1.0, jekyll-theme-tactile-0.1.0, jekyll-theme-time-machine-0.1.0, jekyll-titles-from-headings-0.5.0, jemoji-0.8.1, kramdown-1.14.0, liquid-4.0.0, listen-3.0.6, mercenary-0.3.6, minima-2.1.1, rouge-2.2.1, terminal-table-1.8.0, i18n-0.9.1, minitest-5.10.3, thread_safe-0.3.6, tzinfo-1.2.4, addressable-2.5.2, net-dns-0.8.0, octokit-4.7.0, public_suffix-2.0.5, typhoeus-0.8.0, jekyll-watch-1.5.0, pathutil-0.16.0, safe_yaml-1.0.4, coffee-script-2.4.1, coffee-script-source-1.11.1, html-pipeline-2.7.1, rubyzip-1.2.1, sass-3.5.3, gemoji-3.0.0, rb-fsevent-0.10.2, rb-inotify-0.9.10, unicode-display_width-1.3.0, concurrent-ruby-1.0.5, sawyer-0.8.1, ethon-0.11.0, execjs-2.7.0, nokogiri-1.8.1, sass-listen-4.0.0, ffi-1.9.18, faraday-0.13.1, mini_portile2-2.3.0, multipart-post-2.0.0 in any of the sources                                                                                                                                                                                                                                   
Run `bundle install` to install missing gems.
nabe@zakuro:~/HW (master *=)
$ ls blog
_album  _config.yml  _includes  _layouts  _plugins  _posts  _sass  about.md  css  feed.xml  images  index.html  plugins  portfolio  resume
nabe@zakuro:~/HW (master *=)
$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Using bundler 2.2.30
.. <cut> ..
Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------

まだ他のエラーが生じる

$ bundle exec jekyll serve
bundler: failed to load command: jekyll (/home/nabe/.rbenv/versions/3.0.2/bin/jekyll)
/home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/html.rb:10:in `require': cannot load such file -- rexml/parsers/baseparser (LoadError)
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/html.rb:10:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown/html.rb:10:in `require'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown/html.rb:10:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `require'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown.rb:342:in `require'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown.rb:342:in `<class:Kramdown>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown.rb:60:in `<module:Parser>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown.rb:19:in `<module:Kramdown>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/kramdown-1.14.0/lib/kramdown/parser/kramdown.rb:17:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.6.2/lib/jekyll/converters/smartypants.rb:3:in `require'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.6.2/lib/jekyll/converters/smartypants.rb:3:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.6.2/lib/jekyll.rb:13:in `require'
... <cut> ...
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/exe/bundle:37:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
        from /home/nabe/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'

github-pageアップデートが必要らしい

$ bundle update github-pages
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
... <cut> ...
Fetching github-pages 221 (was 171)
Installing github-pages 221 (was 171)
Bundle updated!
Post-install message from dnsruby:
Installing dnsruby...
  For issues and source code: https://github.com/alexdalitz/dnsruby
  For general discussion (please tell us how you use dnsruby): https://groups.google.com/forum/#!forum/dnsruby
Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Post-install message from rubyzip:
RubyZip 3.0 is coming!
**********************

The public API of some Rubyzip classes has been modernized to use named
parameters for optional arguments. Please check your usage of the
following classes:
  * `Zip::File`
  * `Zip::Entry`
  * `Zip::InputStream`
  * `Zip::OutputStream`

Please ensure that your Gemfiles and .gemspecs are suitably restrictive
to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
See https://github.com/rubyzip/rubyzip for details. The Changelog also
lists other enhancements and bugfixes that have been implemented since
version 2.3.0.

サーバーを起動しようとして、’Hash into Integer’のエラーが生じる。これが rubyバージョン に依るエラーである。jekyllがruby 3.Xに対応していないことに依る。

$ bundle exec jekyll serve  
Configuration file: /home/nabe/HW/_config.yml
            Source: /home/nabe/HW
       Destination: /home/nabe/HW/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.019 seconds.
jekyll 3.9.0 | Error:  no implicit conversion of Hash into Integer
/home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/pathutil-0.16.2/lib/pathutil.rb:502:in `read': no implicit conversion of Hash into Integer (TypeError)
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/pathutil-0.16.2/lib/pathutil.rb:502:in `read'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/utils/platforms.rb:75:in `proc_version'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/utils/platforms.rb:40:in `bash_on_windows?'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/build.rb:77:in `watch'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/build.rb:43:in `process'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve.rb:93:in `block in start'
... <cut> ...
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/lib/bundler/cli.rb:25:in `start'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/exe/bundle:49:in `block in <top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /home/nabe/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bundler-2.2.30/exe/bundle:37:in `<top (required)>'
        from /home/nabe/.rbenv/versions/3.0.2/bin/bundle:23:in `load'
        from /home/nabe/.rbenv/versions/3.0.2/bin/bundle:23:in `<main>'

rbenv install -lで最新の 2.7.x が 2.7.4 であることを確認。 rbenv install 2.7.4でrubyバージョンを古くする。

$ rbenv install 2.7.4
Downloading ruby-2.7.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.4.tar.bz2
Installing ruby-2.7.4...
Installed ruby-2.7.4 to /home/nabe/.rbenv/versions/2.7.4

nabe@zakuro:~/HW (master *=)
$ rbenv which
Usage: rbenv which <command>
nabe@zakuro:~/HW (master *%=)
$ rbenv which ruby
/home/nabe/.rbenv/versions/3.0.2/bin/ruby
nabe@zakuro:~/HW (master *%=)
$ rbenv global 2.7.4
nabe@zakuro:~/HW (master *%=)
$ rbenv which ruby  
/home/nabe/.rbenv/versions/2.7.4/bin/ruby
nabe@zakuro:~/HW (master *%=)
$ ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]

改めてサーバーを起動すると…jekyllが無い。バージョンごとにインストールが必要なのだな。bundelr installを実行

nabe@zakuro:~/HW (master *%=)
$ bundle exec jekyll serve
rbenv: jekyll: command not found

The `jekyll' command exists in these Ruby versions:
  3.0.2

nabe@zakuro:~/HW (master *%=)
$ bundler install
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.30). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.2.30`.
Fetching gem metadata from https://rubygems.org/.........
Fetching concurrent-ruby 1.1.9
Installing concurrent-ruby 1.1.9
Fetching i18n 0.9.5
... <cut> ...
Bundle complete! 3 Gemfile dependencies, 102 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Post-install message from dnsruby:
Installing dnsruby...
  For issues and source code: https://github.com/alexdalitz/dnsruby
  For general discussion (please tell us how you use dnsruby): https://groups.google.com/forum/#!forum/dnsruby
Post-install message from sass:

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Post-install message from rubyzip:
RubyZip 3.0 is coming!
**********************

The public API of some Rubyzip classes has been modernized to use named
parameters for optional arguments. Please check your usage of the
following classes:
  * `Zip::File`
  * `Zip::Entry`
  * `Zip::InputStream`
  * `Zip::OutputStream`

Please ensure that your Gemfiles and .gemspecs are suitably restrictive
to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
See https://github.com/rubyzip/rubyzip for details. The Changelog also
lists other enhancements and bugfixes that have been implemented since
version 2.3.0.

jekyllの起動確認とサーバーの起動

nabe@zakuro:~/HW (master *%=)
$ jekyll
Warning: the running version of Bundler (2.1.4) is older than the version that created the lockfile (2.2.30). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.2.30`.
A subcommand is required. 
jekyll 3.9.0 -- Jekyll is a blog-aware, static site generator in Ruby

Usage:

  jekyll <subcommand> [options]

Options:
        -s, --source [DIR]  Source directory (defaults to ./)
        -d, --destination [DIR]  Destination directory (defaults to ./_site)
            --safe         Safe mode (defaults to false)
        -p, --plugins PLUGINS_DIR1[,PLUGINS_DIR2[,...]]  Plugins directory (defaults to ./_plugins)
            --layouts DIR  Layouts directory (defaults to ./_layouts)
            --profile      Generate a Liquid rendering profile
        -h, --help         Show this message
        -v, --version      Print the name and version
        -t, --trace        Show the full backtrace when an error occurs

Subcommands:
  docs                  
  import                
  build, b              Build your site
  clean                 Clean the site (removes site output and metadata file) without building.
  doctor, hyde          Search site and print specific deprecation warnings
  help                  Show the help message, optionally for a given subcommand.
  new                   Creates a new Jekyll site scaffold in PATH
  new-theme             Creates a new Jekyll theme scaffold
  serve, server, s      Serve your site locally
nabe@zakuro:~/HW (master *%=)
$ bundle exec jekyll serve
Configuration file: /home/nabe/HW/_config.yml
            Source: /home/nabe/HW
       Destination: /home/nabe/HW/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
                    done in 0.026 seconds.
/home/nabe/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/pathutil-0.16.2/lib/pathutil.rb:502: warning: Using the last argument as keyword parameters is deprecated
 Auto-regeneration: enabled for '/home/nabe/HW'
    Server address: http://127.0.0.1:4000
  Server running... press ctrl-c to stop.

一旦、動作するとあっけない。

追加したこの記事も問題なくhtmlに変換された。これでportfolioとresumeの更新の下準備ができた。急がないでマイペースで参りましょう。…自分ブラックカンパニーに留意して… あ、思い出すことがもう一つあった。cat73220.github.ioの更新方法を調べないと。