rails sunspot nokogiri dependency - ruby-on-rails

I am trying to follow the wiki instructions for getting sunspot on rails
https://github.com/outoftime/sunspot/wiki/Adding-Sunspot-search-to-Rails-in-5-minutes-or-less
Everything works fine until when I do:
$ rake sunspot:solr:start
rake aborted!
no such file to load -- nokogiri
However, it looks like I DO have nokogiri installed:
$ gem list
....
nokogiri (1.4.4)
....
Anyone have any thoughts? I'm on a mac if that makes a difference.

Are you including nokogiri in your Gemfile or environment.rb?
For rails 3 add this line to your Gemfile
gem 'nokogiri'
For rails 2 add config.gem to your environment.rb
config.gem "nokogiri"
It's also quite possible if you're using Rails 3 that your gem list command doesn't reflect the directory where bundler has installed the gems for your app.

Related

awesome_print integration with pry - getting dependencies.rb:247:in `require' error

I am trying to use awesome_print (1.2.0) with pry. Both gem awesome_print (1.2.0) and Pry version 0.10.1 is installed on Ruby 2.1.2.
Currently i am able to use run pry while running rails console, however i am not able to make awesome_print work with pry.
Currently i am working on mac and as per the instruction in https://github.com/michaeldv/awesome_print, i need to create ~/.pryrc with the following command:
require "awesome_print"
AwesomePrint.pry!
However, while running rails console i am getting following error:
Please do it first
bundle show awesome_print
And if you do not get any error then it is showing the path of that gem
else
in Gemfile
gem 'awesome_print'
and
bundle install
Then
bundle exec rails c
And in console you get
`require "awesome_print"`
it will return true

Sunspor Solr in production

I saw this question Setup sunspot solr with rails in production environment.
But I see my output:
bundle exec sunspot-solr start
...sunspot_solr is not part of the bundle. Add it to Gemfile.
I have sunspot_solr under development group, and I suppose I should not change that.
Bundler output
Using rsolr (1.0.8)
...
Using sunspot (1.3.3)
Using sunspot_rails (1.3.3)
Rake output
rake sunspot:solr:start RAILS_ENV=production
Note: This task has been moved to the sunspot_solr gem. To install, start and
stop a local Solr instance, please add sunspot_solr to your Gemfile:
group :development do
gem 'sunspot_solr'
end
Any advice, thanks.
Can you try putting the gems outside the development group?
I have the following gems outside the development group:
gem 'sunspot_rails'
gem 'sunspot_solr'

no such file to load -- rack/openid

I am working on a rails gem which depends on rack/openid. But when I require it and fire up my application I get this error
no such file to load -- rack/openid
The gem is installed
$ gem list | grep openid
rack-openid (1.3.1, 1.2.0)
ruby-openid (2.1.8)
I've seen this question but it did NOT helped a lot.
Problem with require rack/openid in Rails 3 [native require work properly]
PS: I can require it from Irb just fine
It looks like you haven't added your Gem to the Gemfile, or you haven't added rack-openid as a dependency to your gem.
When Rails starts up, it uses bundler to set up the load path to match the Gemfile.lock file, so even a gem is installed locally you won't be able to require it if it isn't listed there.
Gemfile.lock is created by bundler based on the gems listed in Gemfile and their dependencies.
Make sure the gem you're working on specifies rack-openid as a dependency in its .gemspec, and then add gem 'my-gem-name' to your applications Gemfile (replace my-gem-name with whatever your gem is actually named).

Rails 2.3.8 with thin doesn't work after installing rails 3.0.1

I have several Rails applications with version 2.3.8, which I run using the thin server. I want to install Rails 3.0.1 on the same machine for testing purposes.
The installation worked fine, but after installing Rails 3.0.1, running Rails 2.3.8 applications with thin fails with this error:
>> Using rails adapter
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`,
update your RAILS_GEM_VERSION setting in config/environment.rb for
the Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.
There seems to be a problem with the latest version of rack (1.2.1) installed with Rails 3. If I uninstall rack 1.2.1 and keep only rack 1.1.0, my Rails 2.3.8 applications run with no problem.
Specifying the rack version with config.gem in environment.rb doesn't solve the problem. Unpacking the rack 1.1.0 gem in the vendor/gems directory doesn't change anything either.
With rack 1.2.1, I can't start my Rails 2.3.8 applications. Without rack 1.2.1, I can't start my Rails 3.0.1 applications.
All the solutions I've found online are about unpacking the rack gem, but this doesn't seem to work for me. Is there something else I should be doing?
I have just Ruby 1.9.2p0 installed using RVM system wide and I run apps using Rails 3 & 2.3.10 on the same server using Thin.
You have to setup bundler on your rails 2.3.10 apps (http://gembundler.com/rails23.html).
Here's one of my Gemfiles for a Rails 2.3.10 app. It's important to specify the rack version.
source :gemcutter
gem "rack", "~> 1.1.0"
gem "rails", "~> 2.3.10"
gem "will_paginate", "~> 2.3.15"
gem 'haml'
gem 'mysql2'
gem 'authlogic'
gem 'searchlogic'
gem 'paperclip'
gem 'thin'
For Rails 2.3.10 you have to start thin from in the app directory using:
bundle exec thin start <options here>
If you are using RVM and are trying to start apps from an init script read this: RVM and thin, root vs. local user
Had the same issue with a Rails 2.3.5 app and Thin (1.2.7).
Had to:
gem uninstall rack --version 1.2.1
gem uninstall rack --version 1.1.0
that left me with only version 1.0.1 and then it worked fine.
Like you, I'm going to be in a mess trying to transition an app into Rails 3. One solution is to use rvm (which I already am) and its notion of gemsets which provide isolation for specific gems for specific applications. I've not played with those yet.
Hopefully the 'thin' folks will get this sorted out.
I did manage to run both Rails versions by installing Ruby twice in separate locations.
If anyone finds a way to run with only one Ruby though, I'd be interested to know.

Rails config.gem error on gem installed

I already have installed this gem: googlecharts.rubyforge.org, but I don't want to require it every time I need it on my actions, so I am trying to do it the Rails way:
config.gem 'mattetti-googlecharts'
Then I go and start my server and get this error:
Missing these required gems:
mattetti-googlecharts
You're running: ruby 1.8.7.174 at
/usr/bin/ruby1.8 rubygems 1.3.5 at
/home/laptop/.gem/ruby/1.8,
/var/lib/gems/1.8
Run rake gems:install to install the
missing gems.
But the gem is installed! I also tried this variant:
config.gem 'mattetti-googlecharts', :lib => 'gcharts'
Use RubyGems repository. The GitHub gem is outdated.
$ gem install googlecharts
Then in your app
config.gem 'googlecharts'
You don't need to require gchart because of this. Also note, you were trying to require gcharts.rb, not gchart.rb.

Resources