Is Nokogiri necessary for Rails? - ruby-on-rails

I updated my Ruby from 1.9 to 2.2 and I found that the Nokogiri gem doesn't support Ruby 2.2 on Windows. Nokogiri was not in my Gemfile, but when I run bundle install it is automatically added. Maybe there are some dependency for it?
This is a very small project and I don't understand its necessity for the project.
Is it possible to use Ruby 2.2 without Nokogiri? Or should I downgrade to 1.9 again?

It looks like Nokogiri is required by rails-dom-testing which is required by Action Pack and Action View in Rails 4.2.3, so it seems difficult to bypass it.

It looks like it is a dependency of some gem, which is included in your Gemfile.
You can search for nokogiri in your Gemfile.lock to find a gem which is requiring it.

See https://github.com/sparklemotion/nokogiri/issues/1256
tl;dr, in your Gemfile:
gem 'nokogiri', '>= 1.6.7.rc3'
for Windows.

Related

Two separately namespaced Gemfiles in one Rails app?

I need to require these two gems in my Rails 3.2 app:
gem 'google-adwords-api'
gem 'netsuite'
However, they conflict on the versions of the savon gem. Bundler spits out this:
Bundler could not find compatible versions for gem "savon":
In Gemfile:
google-adwords-api (>= 0) ruby depends on
google-ads-common (~> 0.2.0) ruby depends on
savon (~> 0.9.1) ruby
netsuite (= 0.2.6) ruby depends on
savon (2.3.3)
I absolutely need both gems in my project, so this is what I've tried so far. I've moved the google-adwords-api gem into a custom Rails Engine I named "adx_interface" and mounted it within my Rails app. This engine has it's own Gemfile. If I put this line in my Rails app's Gemfile, then the Bundler error remains:
gem "adx_interface", "0.0.1", :path => "#{File.expand_path(__FILE__)}/../vendor/adx_interface"
Is there some way to namespace this engine so that it's dependencies aren't clashing with the apps dependencies? I've tried excluding the gem "adx_interface" line from the apps Gemfile, but that means I would have to start requiring gems manually instead of relying on Bundler. Is that a viable solution? If so, how do I go about including the google-adwords-api in such a way that it's namespaced properly and it's savon won't clash with netsuite's savon?
For what it's worth, I've personally contacted the author of the google-adwords-api gem. He said he likes the savon 0.9.1 gem and has no plans to ever update to a newer version.
What you are trying to do is exactly against the idea behind Bundler. Bundler exists to help you manage your dependencies and discover conflicts.
There is no clean way to bypass this restriction. The only solution I can think about, is to fork the google-adwords-api gem, bump the dependency and have your Gemfile to point to your custom fork.

bcrypt-ruby - You don't have bcrypt-ruby installed in your application

I'm beginner in Ruby on Rails and trying to learn from http://ruby.railstutorial.org/ I'm creating sample_app and got stuck at chapter 6.
My Ruby version: ruby 2.0.0p195 (2013-05-14) [i386-mingw32]
My Rails version: Rails 4.0.0
I have following line in my GemFile:
gem 'bcrypt-ruby', '~> 3.0.0'
If I type gem list bcrypt-ruby , it shows bcrypt-ruby (3.0.1) . But if I try to create user, I get error saying
You don't have bcrypt-ruby installed in your application. Please add it to your Gemfile and run bundle install
I searched a lot on rails website, bcrypt website & even stackoverflow. But, nothing worked. Please help.
I've faced this issue recently (as have many others). As per ladyruby723 posted here, use gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt' in your gemfile file.
I solved this the same problem by the following line:
gem 'bcrypt-ruby', '~> 3.1.2'
I believe this exact issue is solved in another question. There are actually two error messages produced, this being the higher level one, by searching for the lower level I found the below answer.
can't activate bcrypt-ruby (~> 3.0.0), already activated bcrypt-ruby-3.1.1. Make sure all dependencies are added to Gemfile
add below in gem file
gem 'bcrypt', git: 'https://github.com/codahale/bcrypt-ruby.git', :require => 'bcrypt'
and run bundle install and restart server
Finally... Got it working. I didn't understand the exact issue but I made two important changes. I'm not sure which change made it working.
I uninstalled my old ruby & rails that were installed from railsinstaller. Installed just ruby for my OS (64 bit which I was not able to choose while installing from railsinstaller). Then I installed rails, sqlite3 separately.
Another important change I did is in Gemfile.lock. I think this did the trick. I kept both of the following lines
bcrypt-ruby (3.0.0)
bcrypt-ruby (3.0.0-x86-mingw32)
In my case, the problem was that bcrypt version 3.1.2 was outdated. Fortunately Ruby has a way of installing the most up to date version of a particular gem right from your command line. In this case I typed in
bundle pristine bcrypt
but more generally you can do
bundle pristine gem name
If you think you might be running into a similar issue with a different gem

haml-rails on rails 4.0?

I'm wondering if anyone has run into any snags with the haml-rails gem in Rails 4.0. There is a Rails Cast that says there were some problems but there is not much more mention of this. The gem hosted on GitHub also doesn't explicitly mention support for Rails 4.0. So what's the status on this?
I'm using haml-rails (0.4) in a rails 4 project and everything is working
Haml 4.0.4 have release to support rails 4 application. You can use haml-rails. Now, it doesn't have problem. Include gem package in gem file
gem 'haml-rails'
and bundle the project

Rails - Understanding Gems

I'm using the rails devise gem. I noticed a case sensitivity bug which turns out is fixed in the latest version of devise so I'm thinking about upgrading.
In my gem file I have:
gem 'devise', '~> 1.1.3'
When I run bundle I get:
Using devise (1.1.9)
Why the difference. And what setting should I be using in my gem file to upgrade to the latest and greatest?
Thanks
The ~> in your Gem declaration says that Bundler can install any version up to the next major version, so in this case it could install any version of devise that is => 1.1.3 and < 1.2.0.
Including the ~> is good practice, as it means security updates are automatic if the gem is using versioning correctly; in a production environment, you'll probably want to drop this moniker, though, and just set your gem versions statically to avoid issues.
To update to the latest version of the gem, everytime, just use the following with no second version argument:
gem 'devise'
See more information on the Gemfile format at http://gembundler.com/gemfile.html.
Just use :
gem 'devise'
and you will be getting the latest stable gem :)
The difference is because you're telling to Bundler to use 1.1.3 or a major version of this gem in you system, if you want to use a specific version just put '1.1.9' in the version param.
use bundle update devise to update the devse gem and bundle update to update all the gems (which is not advisable)
http://jsbin.com/ihiqe4
if you know the version number you want, try this (assuming it's 1.2.3):
gem 'devise', '1.2.3'
or just leave out the version number
if it has not been released yet, you can point to it's github repository instead.

Have Rails 2.3.x ignore the i18n gem

I have a Rails 2.3.5 project that uses the localization features of Rails. I also happen to have Rails 3 beta installed (which depends on the i18n gem). Rails 2.3.5 will happily handle localization on it's own (without i18n installed), however if the i18n gem is available, it makes use of it.
Recently I upgraded my gems and now have version 0.3.7 and 0.4.0 of i18n installed. Rails, of course, wants to load and use the latest version which is causing errors in my project. I tried setting the gem version to 0.3.7 which gets around the errors in the web app. However, we're using resque and resque_mailer to delay the sending of messages. When the worker picks up the mailer job from the queue, it ignores my config.gem requirement in environment.rb and uses version 0.4.0 anyway.
Ideally, I'd like to tell Rails to just not use the i18n gem at all. How do I do that?
Update: As of beta 4, Rails 3 now requires i18n version 0.4.1. I don't see how more people aren't running into this problem as it would seem now if you have both Rails 2 and Rails 3 installed, you're going to run into this.
I followed instructions as defined here:
http://gembundler.com/rails23.html
and it worked.
You could use Bundler or RVM's Gemsets to make the i18n gem unavailable from within your app. Or you could upgrade your Rails app.
Freeze the rails version: rake VERSION=2.3.5 rails:freeze:gems
Fix the version in the file vendor/rails/activesupport/lib/active_support/vendor.rb line 24 to: gem 'i18n', '>= 0.1.3', '< 0.4.0'
Or just edit: /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/vendor.rb
And turn gem 'i18n', '>= 0.1.3'
Into gem 'i18n', '0.1.3'

Resources