How to tell the bundle to use specific version of hpricot [duplicate] - ruby

Upgraded to rails 3, and using Bundler for gems, in a mixed platform development group. I am on Windows. When I run Bundle Install it completes succesfully but will not install hpricot. The hpricot line is:
gem "hpricot", "0.8.3", :platform => :mswin
also tried
gem "hpricot", :platform => :mswin
Both complete fine but when I try to do a "bundle show hpricot" I get:
Could not find gem 'hpricot' in the current bundle.
If I do a run a rails console and try "require 'hpricot'" I get:
LoadError: no such file to load -- hpricot
I have manually installed hpricot as well, and still get the above error. This worked fine before moving to rails 3.

Try this in console and then do bundle install, it will work:
gem install hpricot --platform=mswin32

It may be that you are using a version of ruby that was built with MinGW in which case your platform will be 'mingw' rather than 'mswin'. Try changing your Gemfile line to the following:
gem "hpricot", "0.8.3", :platform => :mingw
And if you have other developers that are using the current setup and don't wan to break it for them, change it to this:
gem "hpricot", "0.8.3", :platforms => [:mswin, :mingw]

Related

No such file to load when requiring jruby pg on Heroku

I'm looking to use the jRuby pg gem in a jRuby application. The gem runs fine locally, but when run on heroku it is unable to load the pg gem.
LoadError: no such file to load -- pg
require at org/jruby/RubyKernel.java:1071
require at /app/vendor/ruby-1.9.3-jruby-1.7.19/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:54
(root) at text.rb:19
My Gemfile is:
ruby '1.9.3', :engine => 'jruby', :engine_version => '1.7.19'
gem 'pg', '0.17.1', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master
Heroku bundle show returns:
Gems included by the bundle:
* pg (0.17.1 c236a38)
Heroku ruby -v returns:
jruby 1.7.19 (1.9.3p551) 2015-02-06 fffffff on OpenJDK 64-Bit Server VM 1.8.0_60-cedar14-b24 +jit [linux-amd64]
text.rb contains:
require 'rubygems'
require 'pg'
puts "cool!"
So far I have:
run bundle locally and repushed
run bundle install locally and repushed
cleared Gemfile.lock repushed and then run bundle on heroku
updated heroku toolbelt
updated ruby gems
checked to see that I'm running the same version of jruby locally and on heroku
uninstalled pg gem and reinstalled
required rubygems in the text.rb file
required the absolute path of pg.rb on heroku, this resulted in an unable to load pg_ext error
In order for this to work, you'll need to prefix your Procfile command with bundle exec (because it's a non-standard gem Heroku can't put it on the path automatically).
For example:
test: bundle exec ruby text.rb
However, this will add a bit of overhead to your JRuby startup time because Bundler has to launch two JRuby processes (one for itself, and then another with the correct gem context).
Another option is to use the activerecord-jdbcpostgresql-adapter, which is more widely adopted.

Can't find rubygem when it is clearly there?

I've just made a little gem and pushed it to Rubygems.org:
https://rubygems.org/gems/fragrant_wind
However, I can't seem to download it again, any ideas?
$ gem install fragrant_wind
ERROR: Could not find a valid gem 'fragrant_wind' (>= 0) in any repositor
Try fixing your gem name. Choose either underscores or hyphens, but don't mix them.
For example you have:
# .gemspec
s.name = 'fragrant-wind'
Better is:
# fragrant_wind.gemspec
s.name = 'fragrant_wind'
Edit 1: it works for me to download then install, but it doesn't work via RubyGems.
$ gem install fragrant_wind-0.0.2.gem
Successfully installed fragrant_wind-0.0.2
1 gem installed
Installing ri documentation for fragrant_wind-0.0.2...
Building YARD (yri) index for fragrant_wind-0.0.2...
Installing RDoc documentation for fragrant_wind-0.0.2...
$ irb
> require 'fragrant_wind'
=> true
> FragrantWind.new.generate
=> "billowing waterfall"
Edit 2: it works via bundler too.(Thanks to #Bitterzoet for this)
# Gemfile
source 'https://rubygems.org'
gem "fragrant_wind"
$ bundle install
Fetching gem metadata from https://rubygems.org/..
Installing fragrant_wind (0.0.2)
Using bundler (1.2.3)
Your bundle is complete! ...
Edit 3: it works now as expected (Monday 10 a.m. PST). My guess is Rubygems was having a delay or glitch due to its own update last night.

Ruby : trying to install rubyXL gem from file

I am just starting with Ruby on Rails and need to use the RubyXL gem (https://github.com/gilt/rubyXL). I was told by one of the other devs to use bundle install. I cannot seem to get the syntax correct however, if I run "bundle install ./rubyXL-1.2.10.gem" I get ""install" was called incorrectly. Call as "bundle install".". How do I use bund
If you need bundler you can add
gem 'rubyXL', :path => '_path_to_file_'
to your Gemfile
You want gem install ./rubyXL-1.2.10.gem.

Issue installing Nokogiri Gem w/ Rails: "Could not find "Nokogiri..."

Nokogiri is in my gem file. Bundle install returns the expected output:
Using nokogiri (1.4.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
When trying to execute db:create:all I get the following error:
rake db:create:all
Could not find nokogiri-1.4.4 in any of the sources
If I test in irb, I also get the expected output.
irb(main):003:0> require "rubygems"
=> true
irb(main):004:0> require "nokogiri"
=> true
I have uninstalled and install nokogiri along with its dependencies multiple times.
I'm using:
Rails 3.0.6
Ruby 1.8.7
Any help would be greatly appreciated.
EDIT: 4/25/11 3:02pm EDT
For comment below: Gemfile line for nokogiri is
gem "nokogiri", '1.4.4', :require => "nokogiri"
I made a test with your case in mind.
My Gemfile is like this:
gem "nokogiri", '1.4.4', :require => "nokogiri"
And then rake db:migrate worked just fine
This may be a long shot but you could try:
bundle install --no-deployment
If you are in deployment mode Rails will look for your gems in the vendor directory, rather then the usual install location. It can cause this kind of error.

Ruby 1.9 - no such file to load 'win32/open3'

I'm running ruby 1.9.2 on Windows and am trying to port code that worked in Ruby 1.8. The code uses Open4.popen4 which previously worked fine. With 1.9.2 I have done the following:
Installed POpen4 via gem install POpen4
Required POpen4 via require 'popen4'
Attempted to use POpen4 like:
Open4.popen4("cmd") {|io_in,io_out,io_er| ... }
When I do, I get the error:
no such file to load -- win32/open3
If I try and install win32-open3 (gem install win32-open3) I get the error:
win32-open3 requires Ruby version < 1.9.0
Does anyone know how I get around this problem?
Haven't used it, but this might work: https://github.com/matschaffer/win32-open3-19
Adding
gem "win32-open3-19", :platforms => :mingw, :git => "github.com/matschaffer/win32-open3-19.git"
to my Gemfile didn't exactly work.
Here are the steps that solved this for me:
Add this to the Gemfile -> gem 'win32-open3-19', :platforms => :mingw
Run bundle to install win32-open3-19
That was it. For me the git location was unncessary and didn't work.

Resources