Open Jonattb opened 9 months ago
When your app shells out to call wkhtmltopdf
(or anything else), it's running as a user on that system, and that user might not have the rbenv
environment loaded.
It executes the binstub under vendor/bundle/ruby/3.0.0/bin/wkhtmltopdf
, but that's just a ruby file, which halts its own execution because it's running under a different version of Ruby than it was built for.
There's 2 paths we can take here:
The first (harder path) is to make it so that when your app spawns a new process, that that user's shell automatically loads the 3.0 rbenv
environment, so that when it calls ruby
, it's calling out the correct version.
The second (easier method) is to specify an exact path to the binary by adding it's path via configuration to your project like this: __config/initializers/wicked_pdf.rb__
WickedPdf.config = {
exe_path: '/usr/local/bin/wkhtmltopdf',
enable_local_file_access: true
}
You didn't post that you were using a provider gem for wkhtmltopdf
, but if you were, this might look like:
exe_path: "#{ENV['GEM_HOME']}/gems/wkhtmltopdf-binary-#{Gem.loaded_specs['wkhtmltopdf-binary'].version}/bin/wkhtmltopdf_linux_amd64"
I have an error with the ruby version. I use rbenv to install ruby and I have two versions, system and 3.0.3. When I do
rbenv shell system
and thenruby -v
I get 2.5.1the error I get is
I don't know why I get 2.5.1 if I use 3.0.3
wicked_pdf gem version (output of cat Gemfile.lock | grep wicked_pdf): 2.7.0
wkhtmltopdf version (output of wkhtmltopdf --version): 0.12.6 (with patched qt)
whtmltopdf provider gem and version if one is used:
platform/distribution and version (e.g. Windows 10 / Ubuntu 16.04 / Heroku cedar): Ubuntu 18.04.6 LTS