'jekyll serve throws 'no implicit conversion of Hash into Integer ' error

I am following Michael Hartl's Learn Enough CSS course. My current folder layout is as follow:

- _layouts
- _site
index.html

where index.html is:

---
layout: test
---

and I have test.html in _layouts as:

Hello again, world.

Whenever I run jekyll serve, I get this error:

Error reading file /Users/pj/Documents/LETGD/repos/pohjie.github.io/_layouts/test.html: no implicit conversion of Hash into Integer 
Error reading file /Users/pj/Documents/LETGD/repos/pohjie.github.io/index.html: no implicit conversion of Hash into Integer 

Does anyone have any idea what's happening? I'm using M1 MacBook, not sure if that is a possible cause as I spent a lot of time install Ruby as well.

Thanks!



Solution 1:[1]

Quoting from this source:-

Github-Pages uses Jekyll 3.9, which isn’t compatible with Ruby 3. Downgrading to Ruby 2.7 should avoid the problem.

This worked for me.

Solution 2:[2]

Ruby 3.0 deprecated using the last argument as keyword parameters. A double splat ** has to be added before the variable for the behavior to be supported.

It's fairly straightforward to amend locally; the relevant patch is found: here

Which needs to be applid to:

/home/<your_user_name>/gems/gems/pathutil-0.16.2/lib/pathutil.rb

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ragav Y
Solution 2 Liviu Stefan