I'm building an existing asciidoc project on a new machine and while it works on my old machine, on the new one it throws this error:
$ bundle exec asciidoctor-pdf book.adoc
bundler: failed to load command: asciidoctor-pdf (/book/vendor/bundle/ruby/3.1.0/bin/asciidoctor-pdf)
/book/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `require': cannot load such file -- matrix (LoadError)
from /book/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `<top (required)>'
from /book/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `require_relative'
from /book/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `<top (required)>'
from /book/vendor/bundle/ruby/3.1.0/gems/asciidoctor-pdf-1.6.2/lib/asciidoctor/pdf.rb:5:in `require'
from /book/vendor/bundle/ruby/3.1.0/gems/asciidoctor-pdf-1.6.2/lib/asciidoctor/pdf.rb:5:in `<top (required)>'
from /book/vendor/bundle/ruby/3.1.0/gems/asciidoctor-pdf-1.6.2/bin/asciidoctor-pdf:5:in `require'
from /book/vendor/bundle/ruby/3.1.0/gems/asciidoctor-pdf-1.6.2/bin/asciidoctor-pdf:5:in `<top (required)>'
from /book/vendor/bundle/ruby/3.1.0/bin/asciidoctor-pdf:25:in `load'
from /book/vendor/bundle/ruby/3.1.0/bin/asciidoctor-pdf:25:in `<top (required)>'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli/exec.rb:58:in `load'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli/exec.rb:58:in `kernel_load'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli/exec.rb:23:in `run'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli.rb:484:in `exec'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli.rb:31:in `dispatch'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/cli.rb:25:in `start'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/exe/bundle:48:in `block in <top (required)>'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
from /book/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.8/exe/bundle:36:in `<top (required)>'
from /opt/homebrew/opt/ruby/bin/bundle:25:in `load'
from /opt/homebrew/opt/ruby/bin/bundle:25:in `<main>'
I'm using bundler
2.3.8 and my Gemfile
source is:
source 'https://rubygems.org'
gem 'asciidoctor', "2.0.17"
gem 'asciidoctor-pdf', "1.6.2"
Cause
This
asciidoctor-pdf
error is casued by aprawn
2.4 compatibily issue with ruby 3.1 that will be solved in the next prawn release.Since
prawn
2.4 is a dependency ofasciidoctor-pdf
1.6.2, it doesn't works onruby
> 3.0.x.Solution
In order to avoid this error, you need to use a compatible
ruby
version like 3.0.3 or >2.5.You can install it easily using a version manager like rvm or asdf.