pathutil.rb:502: warning: Using the last argument as keyword parameters is deprecated
kindrowboat opened this issue ยท 7 comments
- I tried updating to the latest version
- I can't, there is an issue
- This is about an < latest
- I understand older versions may be unsupported
- I Am on Windows
- Ubuntu Bash on Windows
- Fedora Bash on Windows
- Other Bash on Windows
- I Am on Linux
- Ubuntu
- Fedora
- CentOS
- Redhat
- Debian
- I am on macOS 10.13
- I am on macOS 10.14
- I'm on Docker
- I understand Docker may be unsupported
Description
Using ruby 2.7.0, when starting a local development jekyll server (which uses pathutil 16.2), I see the following warning:
/home/motevets/workspace/test/vendor/bundle/ruby/2.7.0/gems/pathutil-0.16.2/lib/pathutil.rb:502: warning: Using the last argument as keyword parameters is deprecated.
It looks like this deprecation warning is in preparation for ruby 3. See "Separation of positional and keyword arguments in Ruby 3.0".
Steps
- install ruby 2.7.0
- install latest Jekyll
- create new Jekyll project, which will use the latest pathutil (16.2)
- run local development server
Output
gem install jekyll #latest
git init test
cd test
jekyll new .
bundle exec jekyll serve
Configuration file: /home/motevets/workspace/test/_config.yml
Source: /home/motevets/workspace/test
Destination: /home/motevets/workspace/test/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.389 seconds.
/home/motevets/workspace/test/vendor/bundle/ruby/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/motevets/workspace/test'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
Note the warning after the Jekyll Feed
step.
Expected
Configuration file: /home/motevets/workspace/test/_config.yml
Source: /home/motevets/workspace/test
Destination: /home/motevets/workspace/test/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
done in 0.389 seconds.
Auto-regeneration: enabled for '/home/motevets/workspace/test'
Server address: http://127.0.0.1:4000/
Server running... press ctrl-c to stop.
Note the lack warning after the Jekyll Feed
step.
Apparently this is now causing the gem to outright break under Ruby 3.0.0...
jekyll 3.9.0 | Error: no implicit conversion of Hash into Integer
/SNIP/vendor/bundle/ruby/3.0.0/gems/pathutil-0.16.2/lib/pathutil.rb:502:in `read': no implicit conversion of Hash into Integer (TypeError)
@ISSOtm I am also stuck with the same issue, did you find any solution for that?
I reverted to bundler-2.7
. I could fix that issue by using the new keyword syntax (*args
or something like that IIRC), but it stumbled further, and I'm not proficient enough in Ruby to fix that one.
I got this on a jekyll project as well with ruby 3.0.1. Reverted to Ruby2.7 for the time being but I hope this is fixed soon.
I was able to make it work on ruby 3.0.1 by the changes suggested in this #5 PR.
More explicit steps for those intimidated by the process of editing a file such as pathutil.rb
...
- in the error output stack trace, take note of the location of the pathutil.rb file. For users of rbenv, you can open the file for editing with a command that looks something like:
vim /home/<YOUR-USERNAME>/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/pathutil-0.16.2/lib/pathutil.rb
Then find occurrences of kwd
that are changed to **kwd
as mentioned in the issue #5 commit 3451a10#diff-5372ed4218752c3077f741296df57da67756dca1d282c64fcced144fc82cd204
For example, the read
method starting around line 498 will now look like (also added a comment referencing the commit above):
def read(*args, **kwd)
kwd[:encoding] ||= encoding
if normalize[:read]
# updates based on https://github.com/envygeeks/pathutil/pull/5/commits/3451a10c362fc867b20c7e471a551b31c40a0246#diff-5372ed4218752c3077f741296df57da67756dca1d282c64fcced144fc82cd204
File.read(self, *args, **kwd).encode(universal_newline: true)
else
File.read(
self, *args, **kwd
)
end
end
Repeat for other occurrences, save, then try something like bundle exec jekyll serve
or whatever command you were doing...good luck .
That updated file is now saved just on your system, under that specific ruby version.
Jekyll v3.9.2 finally removed Jekyll's main dependency on pathutil (jekyll/jekyll@55e3648). Now that Github Pages updated to that version of Jekyll (see github/pages-gem#833), this issue shouldn't affect Github pages or Jekyll anymore.