cortiz / prawn-rails

Prawn Handler for Rails. Handles and registers pdf formats.
MIT License
145 stars 39 forks source link

Issue running on Ruby 3.1 or 3.2 because official prawn gem hasnt released a new version. #47

Closed joemasilotti closed 2 months ago

joemasilotti commented 1 year ago

Hi there! I'm running into issues deploying an app to Heroku with this gem. These are the logs which look like the error is coming from prawn-rails. Any ideas on what could be going on? Thanks!

-----> Building on the Heroku-20 stack
-----> Using buildpacks:
       1. heroku-community/apt
       2. heroku/ruby
       3. https://github.com/brandoncc/heroku-buildpack-vips
-----> Apt app detected
-----> Reusing cache
-----> Updating apt caches
       Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
       Get:2 http://archive.ubuntu.com/ubuntu focal-security InRelease [114 kB]
       Hit:3 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
       Get:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
       Get:5 http://archive.ubuntu.com/ubuntu focal-security/main amd64 Packages [2,774 kB]
       Get:6 http://archive.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1,057 kB]
       Get:7 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,353 kB]
       Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3,253 kB]
       Fetched 8,664 kB in 2s (5,311 kB/s)
       Reading package lists...
-----> Fetching .debs for libglib2.0-0
       Reading package lists...
       Building dependency tree...
       0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 43 not upgraded.
       Need to get 0 B/1,287 kB of archives.
       After this operation, 0 B of additional disk space will be used.
       Download complete and in download only mode
-----> Fetching .debs for libglib2.0-dev
       Reading package lists...
       Building dependency tree...
       0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 43 not upgraded.
       Need to get 0 B/1,506 kB of archives.
       After this operation, 0 B of additional disk space will be used.
       Download complete and in download only mode
-----> Fetching .debs for libpoppler-glib8
       Reading package lists...
       Building dependency tree...
       0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 43 not upgraded.
       Need to get 0 B/109 kB of archives.
       After this operation, 0 B of additional disk space will be used.
       Download complete and in download only mode
-----> Installing libglib2.0-0_2.64.6-1~ubuntu20.04.4_amd64.deb
-----> Installing libglib2.0-dev_2.64.6-1~ubuntu20.04.4_amd64.deb
-----> Installing libnspr4_2%3a4.25-1_amd64.deb
-----> Installing libnss3_2%3a3.49.1-1ubuntu1.7_amd64.deb
-----> Installing libnss3_2%3a3.49.1-1ubuntu1.8_amd64.deb
-----> Installing libnss3_2%3a3.49.1-1ubuntu1.9_amd64.deb
-----> Installing libpoppler97_0.86.1-0ubuntu1.1_amd64.deb
-----> Installing libpoppler97_0.86.1-0ubuntu1_amd64.deb
-----> Installing libpoppler-glib8_0.86.1-0ubuntu1.1_amd64.deb
-----> Installing libpoppler-glib8_0.86.1-0ubuntu1_amd64.deb
-----> Writing profile script
-----> Rewrite package-config files
-----> Ruby app detected
-----> Installing bundler 2.3.25
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.1.2
-----> Installing dependencies using bundler 2.3.25
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Fetching gem metadata from https://rubygems.org/.........
       Using rake 13.0.6
       Using concurrent-ruby 1.2.2
       Using minitest 5.18.0
       Using builder 3.2.4
       Using mini_portile2 2.8.1
       Using racc 1.6.2
       Using crass 1.0.6
       Using rack 2.2.7
       Using nio4r 2.5.9
       Using websocket-extensions 0.1.5
       Using marcel 1.0.2
       Using mini_mime 1.1.2
       Using date 3.3.3
       Using timeout 0.3.2
       Using public_suffix 4.0.7
       Using connection_pool 2.4.1
       Using http-2 0.11.0
       Using ast 2.4.2
       Using gemoji 4.0.0.rc3
       Using redcarpet 3.5.1
       Using rinku 2.0.6
       Using aws-eventstream 1.2.0
       Using aws-partitions 1.519.0
       Using jmespath 1.6.1
       Using bcrypt 3.1.18
       Using bundler 2.3.25
       Using erubi 1.12.0
       Using thor 1.2.1
       Using zeitwerk 2.6.7
       Using orm_adapter 0.5.0
       Using unf_ext 0.0.8.2
       Using faraday-em_http 1.0.0
       Using faraday-em_synchrony 1.0.0
       Using faraday-excon 1.1.0
       Using faraday-httpclient 1.0.1
       Using multipart-post 2.1.1
       Using faraday-net_http 1.0.1
       Using faraday-net_http_persistent 1.2.0
       Using faraday-patron 1.0.0
       Using faraday-rack 1.0.0
       Using faraday-retry 1.0.3
       Using ruby2_keywords 0.0.5
       Using ffi 1.15.5
       Using geocoder 1.7.3
       Using hashids 1.0.6
       Using honeybadger 4.9.0
       Using http-form_data 2.3.0
       Using mini_magick 4.11.0
       Using json 2.6.1
       Using pagy 5.2.0
       Using method_source 1.0.0
       Using pg 1.2.3
       Fetching ttfunk 1.7.0
       Using rexml 3.2.5
       Using stripe 8.0.0
       Using timezone_finder 1.5.7
       Using i18n 1.12.0
       Using tzinfo 2.0.6
       Using nokogiri 1.14.3
       Using rack-test 2.1.0
       Using websocket-driver 0.7.5
       Using net-protocol 0.2.1
       Using addressable 2.8.0
       Using net-http2 0.18.4
       Using auto_html 2.1.0
       Using aws-sigv4 1.4.0
       Using warden 1.2.9
       Using parser 3.1.2.0
       Using puma 5.6.4
       Using rack-attack 6.6.1
       Using redis-client 0.14.1
       Using sprockets 4.0.2
       Using unf 0.1.4
       Fetching pdf-core 0.9.0
       Using ffi-compiler 1.0.1
       Using faraday-multipart 1.0.3
       Using postmark 1.22.0
       Using activesupport 7.0.4.3
       Using ruby-vips 2.1.4
       Using loofah 2.20.0
       Using net-pop 0.1.2
       Using net-smtp 0.3.3
       Using apnotic 1.7.0
       Using aws-sdk-core 3.121.3
       Using scout_apm 5.1.1
       Using sidekiq 7.1.1
       Using sitemap_generator 6.1.2
       Using net-imap 0.3.4
       Using domain_name 0.5.20190701
       Using faraday 1.9.3
       Using http-parser 1.2.3
       Using rails-dom-testing 2.0.3
       Using globalid 1.1.0
       Using activemodel 7.0.4.3
       Using groupdate 6.0.1
       Using inline_svg 1.7.2
       Using pundit 2.2.0
       Using view_component 2.69.0
       Using rails-html-sanitizer 1.5.0
       Using aws-sdk-kms 1.50.0
       Using image_processing 1.12.2
       Using mail 2.8.1
       Using http-cookie 1.0.5
       Using actionview 7.0.4.3
       Using activejob 7.0.4.3
       Using activerecord 7.0.4.3
       Using aws-sdk-s3 1.104.0
       Using faraday_middleware 1.2.0
       Using http 4.4.1
       Using actionpack 7.0.4.3
       Using actioncable 7.0.4.3
       Using actionmailer 7.0.4.3
       Using activestorage 7.0.4.3
       Using railties 7.0.4.3
       Using hashid-rails 1.4.1
       Using pg_search 2.3.6
       Using pretender 0.4.0
       Using sprockets-rails 3.4.2
       Using tarpon 0.4.0
       Using fathom_api 0.1.2
       Using postmark-rails 0.22.0
       Using actionmailbox 7.0.4.3
       Using actiontext 7.0.4.3
       Using classy-yaml 0.7.0
       Using cssbundling-rails 1.0.0
       Using responders 3.1.0
       Using turbo-rails 1.3.1
       Using jsbundling-rails 1.0.0
       Using rails-i18n 7.0.3
       Using devise 4.9.0
       Using rails 7.0.4.3
       Using stimulus-rails 0.7.2
       Using invisible_captcha 2.0.0
       Using noticed 1.5.9
       Using pay 6.3.2
       Using devise-i18n 1.10.1
       Using hotwire-rails 0.1.3
       Installing pdf-core 0.9.0
       Installing ttfunk 1.7.0
       Fetching prawn 2.4.0
       Installing prawn 2.4.0
       Fetching prawn-table 0.2.2
       Installing prawn-table 0.2.2
       Fetching prawn-rails 1.4.2
       Installing prawn-rails 1.4.2
       Bundle complete! 57 Gemfile dependencies, 140 gems now installed.
       Gems in the groups 'development' and 'test' were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Bundle completed (2.83s)
       Cleaning up the bundler cache.
-----> Installing node-v16.18.1-linux-x64
-----> Installing yarn-v1.22.19
-----> Detecting rake tasks

 !
 !     Could not detect rake tasks
 !     ensure you can run `$ bundle exec rake -P` against your app
 !     and using the production group of your Gemfile.
 !     rake aborted!
 !     LoadError: cannot load such file -- matrix
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `<top (required)>'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `require_relative'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `<top (required)>'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-rails-1.4.2/lib/prawn-rails.rb:1:in `require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-rails-1.4.2/lib/prawn-rails.rb:1:in `<top (required)>'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `each'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `block in require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `each'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `require'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler.rb:186:in `require'
 !     /tmp/build_c783fe60/config/application.rb:8:in `<top (required)>'
 !     /tmp/build_c783fe60/Rakefile:4:in `require_relative'
 !     /tmp/build_c783fe60/Rakefile:4:in `<top (required)>'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load_rakefile'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:710:in `raw_load_rakefile'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:104:in `block in load_rakefile'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:103:in `load_rakefile'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:82:in `block in run'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
 !     /tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
 !     /tmp/build_c783fe60/bin/rake:4:in `<main>'
 !
/tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/helpers/rake_runner.rb:100:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
ensure you can run `$ bundle exec rake -P` against your app
and using the production group of your Gemfile.
rake aborted!
LoadError: cannot load such file -- matrix
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn/transformation_stack.rb:10:in `<top (required)>'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `require_relative'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-2.4.0/lib/prawn.rb:67:in `<top (required)>'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-rails-1.4.2/lib/prawn-rails.rb:1:in `require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/prawn-rails-1.4.2/lib/prawn-rails.rb:1:in `<top (required)>'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `each'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:55:in `block in require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `each'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler/runtime.rb:44:in `require'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.25/lib/bundler.rb:186:in `require'
/tmp/build_c783fe60/config/application.rb:8:in `<top (required)>'
/tmp/build_c783fe60/Rakefile:4:in `require_relative'
/tmp/build_c783fe60/Rakefile:4:in `<top (required)>'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:29:in `load_rakefile'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:710:in `raw_load_rakefile'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:104:in `block in load_rakefile'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:103:in `load_rakefile'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:82:in `block in run'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/tmp/build_c783fe60/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:80:in `run'
/tmp/build_c783fe60/bin/rake:4:in `<main>'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:967:in `rake'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:69:in `block in run_assets_precompile_rake_task'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:175:in `log'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:63:in `run_assets_precompile_rake_task'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:103:in `block in compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:988:in `allow_git'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/ruby.rb:96:in `compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails2.rb:55:in `compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails3.rb:37:in `compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails4.rb:30:in `compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/rails6.rb:17:in `compile'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:19:in `block in <main>'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/base.rb:175:in `log'
    from /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/bin/support/ruby_compile:18:in `<main>'
 !     Push rejected, failed to compile Ruby app.
 !     Push failed
joemasilotti commented 1 year ago

It looks like Prawn hasn't cut a release for Ruby 3.1 or 3.2 yet. But the issue/commit have been merged.

For now I made the following change to my Gemfile and asked the maintainers to cut a new release of prawn.

diff --git a/Gemfile b/Gemfile
index 4b2235bc..6ee91009 100644
--- a/Gemfile
+++ b/Gemfile
@@ -57,6 +57,7 @@ gem "pagy"
 gem "pay"
 gem "pg_search"
 gem "postmark-rails"
+gem "prawn", github: "prawnpdf/prawn"
 gem "prawn-rails"
 gem "pretender"
 gem "pundit"
westonganger commented 2 months ago

The prawn gem version v2.5.0 resolves this and was released on Mar 5, 2024. https://rubygems.org/gems/prawn/versions/2.5.0