Eric Guo's

Hoping writing JS, Ruby & Rails and Go article, but fallback to DevOps note

Fix Rake 11.3 and Jekyll 0.12.1 Warning Under Ruby 2.7.1


After upgrade ruby to 2.7.1, I found my old octopress give below two warning:

/usr/local/lib/ruby/gems/2.7.0/gems/rake-11.3.0/lib/rake/application.rb:378: warning: deprecated Object#=~ is called on Proc; it always returns nil

Just need change application.rb:378 as below to fix it.

- { |o| o =~ /^-/ }.map(&:downcase).sort.reverse
+ { |o| o.is_a?(String) && o =~ /^-/ }.map(&:downcase).sort.reverse

Another warning is:

/usr/local/lib/ruby/gems/2.7.0/gems/jekyll-0.12.1/lib/jekyll/post.rb:140: warning: URI.escape is obsolete

Just change as below:

- "categories" => { |c| URI.escape(c) }.join('/'),
+ "categories" => { |c| URI.encode_www_form_component(c) }.join('/'),