Home > Software engineering >  bundle exec jekyll build: wrong number of arguments (given 2, expected 1) (ArgumentError)
bundle exec jekyll build: wrong number of arguments (given 2, expected 1) (ArgumentError)

Time:07-08

I am running Ruby version 3.1.2 and am trying to build my Jekyll website. Initially, when I run bundle exec jekyll build I get this error:

LoadError: cannot load such file -- rexml/parsers/baseparser
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:10:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:10:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/paragraph.rb:14:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:345:in `<class:Kramdown>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:60:in `<module:Parser>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:19:in `<module:Kramdown>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown.rb:17:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/converters/smartypants.rb:3:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll.rb:13:in `block in require_all'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `each'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll.rb:12:in `require_all'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll.rb:194:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/exe/jekyll:8:in `require'
  /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/exe/jekyll:8:in `<top (required)>'
  /Users/faraazkh/.gem/ruby/3.1.2/bin/jekyll:25:in `load'
  /Users/faraazkh/.gem/ruby/3.1.2/bin/jekyll:25:in `<top (required)>'

To combat this, I then added gem "webrick" and gem "rexml", "~> 3.2" to the Gemfile and ran bundle install as recommended here.

However, now I run into this error:

jekyll 3.8.6 | Error:  wrong number of arguments (given 2, expected 1)
/Users/faraazkh/.gem/ruby/3.1.2/gems/forwardable-extended-2.6.0/lib/forwardable/extended.rb:29:in `rb_delegate': wrong number of arguments (given 2, expected 1) (ArgumentError)
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/liquid-tag-parser-1.9.0/lib/liquid/tag/parser.rb:34:in `<class:Parser>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/liquid-tag-parser-1.9.0/lib/liquid/tag/parser.rb:12:in `<class:Tag>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/liquid-tag-parser-1.9.0/lib/liquid/tag/parser.rb:11:in `<module:Liquid>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/liquid-tag-parser-1.9.0/lib/liquid/tag/parser.rb:10:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/tag.rb:7:in `require'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/tag.rb:7:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/context.rb:6:in `require_relative'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/context.rb:6:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/filters.rb:5:in `require_relative'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/filters.rb:5:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/env.rb:15:in `require_relative'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets/env.rb:15:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets.rb:21:in `require_relative'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll/assets.rb:21:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll-assets.rb:5:in `require_relative'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-assets-3.0.12/lib/jekyll-assets.rb:5:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/external.rb:58:in `require'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/external.rb:58:in `block in require_with_graceful_fail'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/external.rb:55:in `each'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/external.rb:55:in `require_with_graceful_fail'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/plugin_manager.rb:30:in `require_gems'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/plugin_manager.rb:22:in `conscientious_require'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/site.rb:114:in `setup'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/site.rb:32:in `initialize'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:30:in `new'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:30:in `process'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/jekyll-3.8.6/exe/jekyll:15:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/bin/jekyll:25:in `load'
    from /Users/faraazkh/.gem/ruby/3.1.2/bin/jekyll:25:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:74:in `load'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:28:in `run'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli.rb:463:in `exec'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli.rb:27:in `dispatch'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/cli.rb:18:in `start'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
    from /Users/faraazkh/.gem/ruby/3.1.2/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
    from /Users/faraazkh/.gem/ruby/3.1.2/bin/bundle:25:in `load'
    from /Users/faraazkh/.gem/ruby/3.1.2/bin/bundle:25:in `<main>'

Here is my Gemfile:

source "https://rubygems.org"

gem "autoprefixer-rails"
gem "html-proofer"
gem "image_optim"
gem "jekyll", '3.8.6'
gem "jekyll-assets"
gem "jekyll-paginate"
gem "jekyll-sitemap"
gem "jemoji"
gem "mini_magick"
gem "sass"
gem "sprockets", "~> 3.7"
gem "uglifier"
gem "webrick"
gem "rexml", "~> 3.2"

Here is my Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    activesupport (5.2.8)
      concurrent-ruby (~> 1.0, >= 1.0.2)
      i18n (>= 0.7, < 2)
      minitest (~> 5.1)
      tzinfo (~> 1.1)
    addressable (2.8.0)
      public_suffix (>= 2.0.2, < 5.0)
    autoprefixer-rails (10.4.7.0)
      execjs (~> 2)
    colorator (1.1.0)
    concurrent-ruby (1.1.10)
    em-websocket (0.5.3)
      eventmachine (>= 0.12.9)
      http_parser.rb (~> 0)
    ethon (0.15.0)
      ffi (>= 1.15.0)
    eventmachine (1.2.7)
    execjs (2.8.1)
    exifr (1.3.9)
    extras (0.3.0)
      forwardable-extended (~> 2.5)
    fastimage (2.2.6)
    ffi (1.15.5)
    forwardable-extended (2.6.0)
    fspath (3.1.2)
    gemoji (3.0.1)
    html-pipeline (2.14.2)
      activesupport (>= 2)
      nokogiri (>= 1.4)
    html-proofer (3.19.4)
      addressable (~> 2.3)
      mercenary (~> 0.3)
      nokogiri (~> 1.13)
      parallel (~> 1.10)
      rainbow (~> 3.0)
      typhoeus (~> 1.3)
      yell (~> 2.0)
    http_parser.rb (0.8.0)
    i18n (0.9.5)
      concurrent-ruby (~> 1.0)
    image_optim (0.31.1)
      exifr (~> 1.2, >= 1.2.2)
      fspath (~> 3.0)
      image_size (>= 1.5, < 4)
      in_threads (~> 1.3)
      progress (~> 3.0, >= 3.0.1)
    image_size (3.0.2)
    in_threads (1.6.0)
    jekyll (3.8.6)
      addressable (~> 2.4)
      colorator (~> 1.0)
      em-websocket (~> 0.5)
      i18n (~> 0.7)
      jekyll-sass-converter (~> 1.0)
      jekyll-watch (~> 2.0)
      kramdown (~> 1.14)
      liquid (~> 4.0)
      mercenary (~> 0.3.3)
      pathutil (~> 0.9)
      rouge (>= 1.7, < 4)
      safe_yaml (~> 1.0)
    jekyll-assets (3.0.12)
      activesupport (~> 5.0)
      execjs (~> 2.7)
      extras (~> 0.2)
      fastimage (~> 2.0, >= 1.8)
      jekyll (>= 3.5, < 4.0)
      jekyll-sanity (~> 1.2)
      liquid-tag-parser (~> 1.0)
      nokogiri (~> 1.8)
      pathutil (~> 0.16)
      sprockets (>= 3.3, < 4.1.beta)
    jekyll-paginate (1.1.0)
    jekyll-sanity (1.6.0)
      jekyll (>= 3.1, < 5.0)
      pathutil (~> 0.16)
    jekyll-sass-converter (1.5.2)
      sass (~> 3.4)
    jekyll-sitemap (1.4.0)
      jekyll (>= 3.7, < 5.0)
    jekyll-watch (2.2.1)
      listen (~> 3.0)
    jemoji (0.12.0)
      gemoji (~> 3.0)
      html-pipeline (~> 2.2)
      jekyll (>= 3.0, < 5.0)
    kramdown (1.17.0)
    liquid (4.0.3)
    liquid-tag-parser (1.9.0)
      extras (~> 0.3)
      liquid (>= 3.0, < 5.0)
    listen (3.7.1)
      rb-fsevent (~> 0.10, >= 0.10.3)
      rb-inotify (~> 0.9, >= 0.9.10)
    mercenary (0.3.6)
    mini_magick (4.11.0)
    mini_portile2 (2.8.0)
    minitest (5.16.2)
    nokogiri (1.13.6)
      mini_portile2 (~> 2.8.0)
      racc (~> 1.4)
    parallel (1.22.1)
    pathutil (0.16.2)
      forwardable-extended (~> 2.6)
    progress (3.6.0)
    public_suffix (4.0.7)
    racc (1.6.0)
    rack (2.2.4)
    rainbow (3.1.1)
    rb-fsevent (0.11.1)
    rb-inotify (0.10.1)
      ffi (~> 1.0)
    rexml (3.2.5)
    rouge (3.29.0)
    safe_yaml (1.0.5)
    sass (3.7.4)
      sass-listen (~> 4.0.0)
    sass-listen (4.0.0)
      rb-fsevent (~> 0.9, >= 0.9.4)
      rb-inotify (~> 0.9, >= 0.9.7)
    sprockets (3.7.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    thread_safe (0.3.6)
    typhoeus (1.4.0)
      ethon (>= 0.9.0)
    tzinfo (1.2.9)
      thread_safe (~> 0.1)
    uglifier (4.2.0)
      execjs (>= 0.3.0, < 3)
    webrick (1.7.0)
    yell (2.2.2)

PLATFORMS
  ruby

DEPENDENCIES
  autoprefixer-rails
  html-proofer
  image_optim
  jekyll (= 3.8.6)
  jekyll-assets
  jekyll-paginate
  jekyll-sitemap
  jemoji
  mini_magick
  rexml (~> 3.2)
  sass
  sprockets (~> 3.7)
  uglifier
  webrick

BUNDLED WITH
   1.17.2

I have tried this but no avail. Could not find a solution to this error anywhere else. Any help is much appreciated!

Thanks!

CodePudding user response:

Can you try with newer jekyll version?

So update Gemfile with: gem "jekyll", "~> 4.2.2"

CodePudding user response:

Ruby 3 breaks a few number of gems with this error message because of the separation of positional and keyword arguments in Ruby 3. See this for more info: Separation of positional and keyword arguments in Ruby 3.0

I was able to reproduce your exact problem. In your case it's jekyll-assets 3.0.12 which requires liquid-tag-parser 1.9.0 that creates the second error message. Unfortunately upgrading to Jekyll 4 will not solve this problem.

I found two solutions:

1. Downgrade to Ruby 2.7

This is by far the easiest way to fix this problem.

2. Use jekyll-assets from Github

Proceed at your own risk!

First you will need to use Jekyll 3.9.2 because of another problem between Ruby 3.X and the pathutil gem which is required by Jekyll 3.8.6. Jekyll 3.9.2 drops the dependency on pathutil. Change these lines in your Gemfile:

gem "jekyll", "~>3.9"
gem "sprockets"

You will also need to pull the latest code for jekyll-assets from Github. While looking at this problem, I found further issues with the wrong number of arguments in a few function calls in jekyll-assets. I submitted a pull request to fix those. Modify this line in your Gemfile to use this pull request as source for the gem:

gem "jekyll-assets", git: "https://github.com/envygeeks/jekyll-assets", ref: "refs/pull/666/head"

By doing this, I was able to install the gems and run Jekyll successfully with jekyll-assets. You may also want to consider using another plugin as jekyll-assets hasn't been updated in a few years.

  • Related