'Jekyll error on Ubuntu 22.04 (wrong number of arguments)

Previously, jekyll was working correctly After I upgraded my OS to Ubuntu 22.04 my local jekyll gives me this error.

bundle exec jekyll serve
Configuration file: /home/username/dev/project/main-website/_config.yml
            Source: /home/username/dev/project/main-website/app
       Destination: /home/username/dev/project/main-website/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
       Jekyll Feed: Generating feed for posts
                    ------------------------------------------------
      Jekyll 4.2.2   Please append `--trace` to the `serve` command 
                     for any additional information or backtrace. 
                    ------------------------------------------------
/home/username/gems/bundler/gems/jekyll-assets-056d2c88719e/lib/jekyll/assets/patches/writer.rb:53:in `after_hook': wrong number of arguments (given 2, expected 1; required keywords: asset, env) (ArgumentError)
    from /home/username/gems/bundler/gems/jekyll-assets-056d2c88719e/lib/jekyll/assets/patches/writer.rb:28:in `call'
    from /home/username/gems/gems/sprockets-4.0.3/lib/sprockets/manifest.rb:196:in `block (3 levels) in compile'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `block in synchronize'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:47:in `synchronize'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
    from /home/username/gems/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker'

I went to look at the environment settings and see this:

ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

bundle -v
Bundler version 2.3.12

jekyll -v
jekyll 4.2.2

Any suggestion or help would be appreciated as I’d rather not have to downgrade my system. If there’s more info I should provide or some docs I should read, please let me know



Solution 1:[1]

I had the same problem, I solved it by doing the following command:

bundle add webrick

Solution 2:[2]

I had the very same problem, and for me, Steve's solution also did not work for me.

To be on the same page, I first state my situation clearly:

  • I had a working jekyll version running on 21.04, I then upgraded to 21.10, then directly to 22.04 -- now I get the same error message.
  • ruby -v returns ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]
  • bundle -v returns Bundler version 2.2.5
  • jekyll -v doesn't return any version, but an error message instead. The version still seems to be 4.2.2, which I infer from the error message:

/var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll/drops/collection_drop.rb:10:in <class:CollectionDrop>': undefined method delegate_method_as' for Jekyll::Drops::CollectionDrop:Class (NoMethodError) from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll/drops/collection_drop.rb:5:in <module:Drops>' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll/drops/collection_drop.rb:4:in module:Jekyll' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll/drops/collection_drop.rb:3:in <top (required)>' from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require' from internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in require' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll.rb:13:in block in require_all' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll.rb:12:in each' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll.rb:12:in require_all' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/lib/jekyll.rb:191:in <top (required)>' from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:85:in require' from internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in require' from /var/lib/gems/3.0.0/gems/jekyll-4.2.2/exe/jekyll:8:in <top (required)>' from /usr/local/bin/jekyll:25:in load' from /usr/local/bin/jekyll:25:in '

(I'm sorry it that's not formatted well, I'm not sure how to do it differently -- feel free to edit. :))

Anyway, as hypothesized on various other internet sources I assume(d) the problem is the wrong ruby version. I also expect this due to two reasons:

  • I got it to work by downgrading to ruby2.7 (from 3.0)
  • I initially even had a different error message (when calling jekyll serve right after the system upgrade I got the error message /usr/bin/env: ‘ruby2.7’: No such file or directory. It disapperared after performing sudo gem update jekyll and sudo bundle install)

I'd love to give a manual how to install ruby2.7, but honestly I'm not sure which exact sequence of steps I performed since there were so many different explanations on the net, and none of them worked; I have no clue which subsequence of steps was at the end responsible for me being able to do this.

I do however suspect that it was method 2 described here that contributed to it (I repeat it below should that webpage go offline or change). Note that simply following these steps did not work (I needed 2 additional hours). Performing the following commands several times contributed to success:

  1. Perform two commands:

    (a) echo "deb https://ppa.launchpadcontent.net/brightbox/ruby-ng/ubuntu/ focal main"|sudo tee /etc/apt/sources.list.d/brightbox.list

    (b) sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 80F70E11F0F0D5F10CB20E62F5DA5F09C3173AA6

  2. sudo apt update

  3. sudo apt install ruby2.7 <-- this did not work! And this is where a 2 hour debugging process started; hence, I can't say what actually contributed towards getting it work past this point. However, at some point I saw that even after sudo apt-get upgrade two packages were held back, namely ruby and ruby-dev. I could install ruby-dev after installing the packing libssl1.1, and the following StackOverflow post shows how that's done. After installing ruby-dev I was also able to install ruby. Then, finally, I could execute bundle exec jekyll serve (but, I believe i had to execute sudo gem update jekyll and/or sudo bundle install again!)

Although a bit fuzzy towards the end, I hope this helps -- I've literally spend hours getting it work again, so I thought I put together my approach.

I think you'd do the community a favor putting in your exact steps leading to success if my post helps you crack it. I've ran out of systems, so I can't check. :)

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 Tyler2P
Solution 2