An error occured while installing wkhtmtopdf-heroku - ruby-on-rails

Heroku doesn't allow me to put airbrake and wkhtmlpdf-heroku gems together. My previous push works fine without airbrake. If I put airbrake again in my gemfile, the error below results:
Bundler::GemspecError: Could not read gem at /tmp/build_li34yprz7arq/vendor/bundle/ruby/1.9.1/cache/wkhtmltopdf-heroku-1.0.0.gem. It may be corrupted.
An error occurred while installing wkhtmltopdf-heroku (1.0.0), and Bundler
cannot continue.
Do you know any reason why that's happening? Thanks!

The wkhtmltopdf-heroku gem just drops a wkhtmltopdf binary in your project and sets up configs for common 'client' gems. You can just do that yourself manually. I say this because I had some other odd issues tied to that gem that went away mysteriously when I just did setup for myself.
So try just dropping wkhtmltopdf-amd64 in your projects bin directory and do your own config. In my case, for wicked_pdf, that meant a wicked_pdf.rb in /initializers containing
WickedPdf.config = { :exe_path => (Rails.env.test? || Rails.env.development? ? 'c:\Program Files\wkhtmltopdf\wkhtmltopdf.exe' : Rails.root.join('bin', 'wkhtmltopdf-amd64').to_s),
:page_size => 'Letter',
:outline => {:outline => true, :outline_depth => 4}}
Just to clarify, that is pointing to a windows binary on my C drive for test and production, and otherwise (meaning production) pointing to the amd-64 binary (for Heroku) which I have in the project's bin directory.

Related

Loading local gems through Bundler and mounted apps

I'm creating a gem (let's call it mygem) that is essentially a Sinatra server intended to be mounted within Rack based apps.
Inside my gem's gemspec file, I have the following:
gem.add_dependency 'kss'
And Inside my gem's Gemfile, I have the following
source 'https://rubygems.org'
gemspec
gem "kss", :path => "/Users/me/code/kss"
Now when running the server from within mygem's folder, this works exactly as expected: instead of fetching out for the kss dependency, it will look on my local drive and load that version.
The problem comes in when I add mygem to a Rails test app Gemfile. In my Rails test app Gemfile, I have the following line:
gem "mygem", :path => "/Users/me/code/mygem"
I would expect, upon a bundle install, that Bundler would load mygem and its dependencies; but for the kss dependency, instead of loading the local dependency, Bundler actually does fetches out to rubygems to find and load it. I'm assuming because in this case, it's only reading from the gemspec line and not including my dependency override.
Is there anything I can do to fix this behavior? I'd very much like to be able to run and test this stuff locally, but Bundler doesn't seem to recognize dependency overrides from a higher level app.
I'm completely open to any suggestions or changes if I'm going about this the wrong way.
Dependencies listed in your gemspec will become dependencies of the implementing application, while dependencies defined in the Gemfile will not become dependencies of the implementing application. I think you should be able to simply adjust the Rails test app Gemfile to be:
gem "kss", :path => "/Users/me/code/kss"
gem "mygem", :path => "/Users/me/code/mygem"

Local Gem assets not updating

I've forked a gem, and in trying to change it, decided to change the the gemfile from my git repository (which had been updating fine):
gem 'bootstrap-wysihtml5-rails', :git => 'git://github.com/Asherlc/bootstrap-wysihtml5-rails.git'
to the local directory (just the cloned git repository):
gem 'bootstrap-wysihtml5-rails', :path => '/Users/ashercohen/Documents/bootstrap-wysihtml5-rails'
Upon running either bundle update or bundle install, it shows the correct version number (updated since switching gem sources) in the readout. However, none of the files in the /vendor/assetspath seem to be getting updated in my Rails app. Is there some kind of caching thing I need to clear out?
I don't have a /vendor/cache file in my Rails app, and I'm confident that since the gem version is updating correctly in the bundler readout that the path is correct.
Is there some step I'm missing here?
Turns out Chrome was just aggressively caching the JS.

Have Bundler parse and load dependencies from Gemfile/s in gem/s loaded with :path

here's my current situation:
I am working on a rails engine ( "awesome_engine" ). I do all development via a host application, i.e. a rails app that specifies this engine as a dependency in its Gemfile with the :path parameter
gem "awesome_engine", :path => "awesome_engine"
This works well- the engine gem folder is under "awesome_engine" relative to the root of the host application. However "awesome_engine" references a gem that is also in development, "awesome_core". awesome_engine/Gemfile therefore reads:
gem "awesome_common", :path => "../awesome_core"
THe problem with this setup seems to be that Bundler does not look for a Gemfile in awesome_engine/ when it creates the application bundle for the host rails application, it only reads dependencies from the gemspec of "awesome_engine", which is fine for any single gem you'd want to have loaded in its "unpackaged" state, not so great for when you want to work on a graph of related gems at the same time
Am i
a) trying to bite off more than i can chew and should just dump "awesome_core" in the Gemfile of the host app while it is under development and be happy with it ( i won't be :-) )
b) missing something trivial on how to have Bundler do this
c) none of the above ( please specify: ________ )
thanks!
Andras
ps: i know Bundler does not parse "awesome_engine/Gemfile" because a) if i put crap in it bundle install in the host app still runs fine b) none of the other dependencies from that file end up in the host applications app bundle
So when you specify a gem through your (current project's) Gemfile, it is assumed that you are referencing something with well defined dependencies. This means that it is expected that there is a valid .gemspec file that names those dependencies. But this you already know.
My suggestion for c) would be to create your gems with bundle gem which sets up the gem in a way that information for it's Gemfile is drawn from the .gemspec file. Have a look at http://gembundler.com/v1.2/bundle_gem.html and just generate a test gem and read its sources, it's quite clear.
I hope that solves your problem.

Unpacking gems [Rails 2.3.5]

I have the following gems defined in my environment.rb file:
config.gem "authlogic"
config.gem "paperclip"
config.gem "pauldix-feedzirra", :lib => "feedzirra", :source => "http://gems.github.com"
config.gem 'whenever', :lib => false, :source => 'http://gemcutter.org/'
I have them installed on my local computer and everything is working well.
Since I am working on a shared-server (DreamHost), I need to unpack those gems to get them to work (can't install them as I did on my own computer to get them to work).
Before uploading, I ran the following on my local machine:
rake gems:unpack
This created the following folders in /vender/gems:
authlogic-2.1.3, paperclip-2.3.1.1, pauldix-feedzirra-0.0.18, whenever-0.4.1
So it looks like they're all there.
When I run rake db:migrate on the server, though, I get these following error:
Missing these required gems:
pauldix-feedzirra
For some reason, the feedzirra unpacked gem is not detected. Could anybody offer a clue as to why this is happening and a potential solution?
Thanks!
EDIT: Thanks, but the code to put in environment.rb doesn't work, and bundler won't install properly on my server. Any other suggestions?
This isn't exactly an answer, but since I could never get config.gem to work properly, I recommend using Bundler whenever I can. It just works and it handles interdependencies between gems well. It also replaces config.gem in Rails 3 from what I understand.
I notice two things about feedzirra: first, it depends on 3 other gems, and at least one of those build native extensions. And I'm going to call it "feedzirra" - I'm not a fan of github's ill-considered autopackaging fiasco.
If it were only the former, then rake gems:unpack:dependencies would do the trick.
However, at least curb (which feedzirra depends on) is building extensions, and those can't simply be unpacked. You could either get Dreamhost to install them (good luck) or install them into your user's local gem directory.
To do that, you'll need to update your .gemrc and be sure that it includes a line like:
:user_install: true
Then rake gems:install
Unless your deployment environment won't let you build executables, in which case you'll need to shell out for a less restricted package - I know for a fact that Dreamhost does provide packages that will allow for extension-gems.
(And there's the separate issue of libcurl being deployed...)
Try Following.put this code in envoirment.rb
config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = "#{dir}/lib") ? lib : dir
end
Don't know if my hints are useful, because feedzirra is compiled extension (against CURL i think). Better solution is to normally install feedzirra gem (it will compile itself) on your server.
You have not installed (unpacked) feedzirra gem, but pauldix-feedzirra. Probably you need feedzirra unpacked too.
Try to add
config.gem feedzirra
into environment.rb and run locally
rake gems:install
rake gems:unpack
It looks like feedzirra unpacked gem is missing in /vendor/plugins. Look if feedzirra will be copied there after those commands...

Getting Rails to play with Hpricot

I'm trying to get Hpricot working with Rails on my dev machine.
I've installed Hpricot [0.8.1] using the standard 'gem install hpricot' and confirmed it works fine with my standard Ruby installation [1.8.7]; however when I try the same with my Rails [2.1.0] installation, I get an error -
TypeError: superclass mismatch for class BogusETag from /usr/lib/ruby/1.8/hpricot/tag.rb:130
Seems like there's some kind of conflict, but googling the error hasn't turned up any useful information.
Any ideas ? Thanks in advance.
If you're free to choose your HTML parsing library, switch it.
Why, the creator of Hpricot, recently posted that you should better use Nokogiri instead of HPricot, nowadays.
This error occurs because there is no compiled library for the platform. To solve this for your current hpricot version, go to your rails directory dir and do the following (this assumes you are using an unpacked gem - this problem wouldn't arrise otherwise, unless your OS has been upgraded since installing the gem):
cd vendor/gems/hpricot-0.6/ext/hpricot_scan/
ruby extconf.rb
make
Then copy the compiled library to the correct platform dir for your system. Each version of OS X has a slightly different platform name, so mine (Snow Leopard) appears as:
ruby-1.8.6-p383 > RUBY_PLATFORM
=> "i686-darwin10.0.0"
This means I needed to copy the file "hpricot_scan.bundle" (OS X uses bundles for shared libraries, on Linux that would be "hpricot_scan.so") to the following directory, creating it if necessary:
vendor/gems/hpricot-0.6/lib/i686-darwin10.0.0/
Substitute the appropriate platform name (puts RUBY_PLATFORM from irb) for your machine.
Try using Hpricot in a irb session, because i don't think this should generally happen
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'hpricot'
=> true
irb(main):003:0> doc=Hpricot.parse("<html><head><title>test</title></head><body> Wooo Hooo </body></html>")
=> # {elem {elem "test" } } {elem " Wooo Hooo " } }>
irb(main):004:0> doc.search('title')
=> # "test" }]>
irb(main):005:0> doc.search('title').text
=> "test"
That means your Hpricot is working fine. And the problem is in way you are using it in Rails. ( It would be easier if you could paste your code ).
I had few issues with Hpricot(0.8.1) earlier, had to switch back to 0.6.164 version. you can try that if you want.
HTH
Execute Below command and its works
gem install hpricot --platform=mswin32

Resources