Search code examples
ruby-on-railsrubyrubygemswkhtmltopdf

Rails: wkhtmltopdf executable in the wkhtmltopdf-binary-edge gem is being loaded


I am working on a Rails application on Ubuntu 18.04.

I used the wkhtmltopdf-binary-edge, wkhtmltopdf, wkhtmltopdf-binary, wkhtmltopdf-heroku gems to convert HTML to PDF.

I defined it this way in my Gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.5.0'
gem 'rails', '~> 5.2.1'
gem 'pg'
gem 'puma', '~> 3.11'
gem 'wicked_pdf'

group :development, :test do
  gem 'wkhtmltopdf-binary-edge'
end 

group :production do
  gem 'wkhtmltopdf-heroku'
  gem 'wkhtmltopdf-binary'
end 

Everything was working fine until recently when I started encountering this error whenever I try to run bundle install:

Error: The wkhtmltopdfexecutable in thewkhtmltopdf-binary-edge gem is being loaded, but it's also present in other gems (wkhtmltopdf-binary). If you meant to run the executable for another gem, make sure you use a project specific binstub (bundle binstub ). If you plan to use multiple conflicting executables, generate binstubs for them and disambiguate their names.

I have tried a couple of solutions, but none seems to work.


Solution

  • Here's how I solved:

    It seemed like gems wkhtmltopdf-binary-edge and wkhtmltopdf-binary have conflicting executables.

    I simply had to remove the wkhtmltopdf-binary-edge gem and re-ordered the Gemfile this way:

    source 'https://rubygems.org'
    git_source(:github) { |repo| "https://github.com/#{repo}.git" }
    
    ruby '2.5.0'
    gem 'rails', '~> 5.2.1'
    gem 'pg'
    gem 'puma', '~> 3.11'
    gem 'wicked_pdf'
    gem 'wkhtmltopdf-binary'
    
    
    group :production do
      gem 'wkhtmltopdf-heroku'
    end 
    

    That's all.

    I hope this helps