Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem not available, even after adding to gemfile and running bundle install

I'm making a simple task where I need to parse an XML Http response, all the http is working fine, and I have my xml string....

I'm trying to use the xml-simple gem.

I've gem install xml-simple

I've also added gem 'xml-simple' to the gemfile

Ran bundle install with success

but when I try to require 'xml-simple' in my rake task it fails saying no such file to load -- xml-simple...

What am I missing???

like image 403
jondavidjohn Avatar asked Oct 08 '11 05:10

jondavidjohn


People also ask

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from. Save this answer.

Why bundle install is installing gems in vendor bundle?

In deployment, isolation is a more important default. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them. As a result, bundle install --deployment installs gems to the vendor/bundle directory in the application.

How do I set gem version in Gemfile?

There are several ways to specify gem versions: Use a specific version: gem "name-of-gem", "1.0" . You can find specific versions on Rubygems.org (provided that's the source you”re using) by searching for your gem and looking at the “Versions” listed. Use a version operator: gem "name-of-gem", ">1.0" .

How do I install bundles to install missing gems?

Select Tools | Bundler | Install from the main menu. Open the Gemfile, place the caret at any highlighted gem missing in the project SDK and press Alt+Enter . Select Install missing gems using 'bundler' and press Enter .


1 Answers

Bundler tries to load the gem by using the gem name as the require path (i.e. require 'xml-simple'). But in the case of the xml-simple gem, the path is xmlsimple, not xml-simple.

So in your Gemfile, use this instead:

gem 'xml-simple', :require => 'xmlsimple'
like image 73
htanata Avatar answered Nov 14 '22 22:11

htanata