What causes this dependency error in Rails 3? - ruby-on-rails

I now get the following:
`dependencies.rb:239:in `require': no such file to load -- require_relative (LoadError`)
But I don't have enough information to figure out what is causing it or how to debug it.
What can I do?

It probably comes from linecache gem version 0.45 which was released yesterday. Rolling back to 0.43 will get you around this for now. I'm not sure if they intentionally broke support with Ruby 1.8.7 or not.
This is a dependency of ruby-debug-base.
Add something similar to the following in your Gemfile.
group :development, :test, :cucumber do
gem "linecache", "0.43"
gem "ruby-debug-base", "0.10.4.0"
gem "ruby-debug", "0.10.4"
end

Alternatively, add
gem 'require_relative'
to your Gemfile. It looks like linecache 0.45 needs it, but 0.43 doesn't, which is why downgrading linecache works.

Related

How to use a specific Nokogiri version for Rails application

I'm trying to run a Rails application that I wrote a couple of years ago, however I keep getting this error when I run rails server:
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'nokogiri' (>= 1.5.9) - did find: [nokogiri-1.5.6] (Gem::LoadError)
I'm pretty confused, since I have Nokogiri v1.8.2 and v1.10.7 installed and see them under .gem/ruby/2.3.0 and /Library/Ruby/Gems/2.3.0. I don't see Nokogiri v1.5.6 though, so I'm not sure where the application is getting that from.
I tried adding
gem 'nokogiri', '~> 1.10', '>= 1.10.3'
to the Gemfile, as well as
gem 'nokogiri', '~> 1.5.6'
I'm trying to figure out if I can change the GEM_PATH, but hopefully there's another solution I'm not seeing.
Nokogiri is used by Rails, so you don't need to add it to your Gemfile, but you can update the version in your Gemfile.lock using:
bundle update nokogiri

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

Getting Autotest to Work with Growl on OS X

I'm using Ruby 1.9.2 and Rails 3.0.7 on Mac OS X 10.6.7.
I have had the most terrible time getting growl to display autotest notifications. I have autotest installed and working perfectly.
Every time I make a change to a file, the tests are run without a problem. Growl simply refuses to work. In my Growl preferences panel I can see that autotest is added to the list of applications and enabled and Growl is on and running. Here's what my gemfile looks like:
source 'http://rubygems.org'
gem 'rails'
gem 'sqlite3-ruby', :require => 'sqlite3'
group :development do
gem 'rspec-rails'
gem 'annotate-models'
end
group :test do
gem 'rspec'
gem 'webrat'
gem "ZenTest"
gem "autotest-rails-pure"
gem "autotest-growl"
gem "autotest-fsevent"
end
And here's my .autotest file:
require 'autotest/growl'
require 'autotest/fsevent'
I've tried everything I can think of to get this to work. I tried:
following the first two pages of guides on Google for autotest and OS X.
deleting my gemset in RVM and reinstalling.
running bundle install dozens of times.
installing the test_notifier gem.
None of these steps seemed to work. I'd appreciate any help or suggestions. It's been a frustrating two days trying to get this to work.
You might want to consider using Guard-RSpec to run your specs. It's easy to install, and it works with Growl. Be sure to look at the base Guard gem. I've switched over from Autotest over a month ago and have been happy. Here's the Railscasts about Guard.
Have you tried putting gem 'autotest-growl' in your development group? I've always put it there and have had no problems; I've just assumed it's the same reason that you have gem 'rspec-rails' in your development group.

Help with Ruby on Rails Gem file and bundle install

I am trying to learn rails from http://ruby.railstutorial.org/
Exercise 3 explains to install rspec, rspec-rails, and webrat using this gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.6'
gem 'sqlite3', '1.3.3', :require => 'sqlite3'
group :development do
gem "rspec-rails", ">= 2.0.1"
end
group :test do
gem "rspec-rails", ">= 2.0.1"
gem 'rpsec'
gem 'webrat'
end
i have tried to install rspec-rails and webrat and they seem to have installed correctly.
C:\RubyProject\sample_app>gem install rspec-rails -v=2.0.1
**************************************************
Thank you for installing rspec-rails-2.0.1!
This version of rspec-rails only works with versions of rails >= 3.0.0
To configure your app to use rspec-rails, add a declaration to your Gemfile.
If you are using Bundler's grouping feature in your Gemfile, be sure to include
rspec-rails in the :development group as well as the :test group so that you
can access its generators and rake tasks.
group :development, :test do
gem "rspec-rails", ">= 2.0.1"
end
Be sure to run the following command in each of your Rails apps if you're
upgrading:
script/rails generate rspec:install
Even if you've run it before, this ensures that you have the latest updates
to spec/spec_helper.rb and any other support files.
Beta versions of rspec-rails-2 installed files that are no longer being used,
so please remove these files if you have them:
lib/tasks/rspec.rake
config/initializers/rspec_generator.rb
Lastly, be sure to look at Upgrade.markdown to see what might have changed
since the last release.
**************************************************
Successfully installed rspec-rails-2.0.1
1 gem installed
Installing ri documentation for rspec-rails-2.0.1...
Installing RDoc documentation for rspec-rails-2.0.1...
But when i run bundle install
I get the following error message
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
So me being a total newbie to RoR has no idea why this is occurring. I have tried following this link
http://railsforum.com/viewtopic.php?id=41464
which seems to be a dead end. I'm hoping that someone here can point me in the right direction. Any help would be appreciated.
If your output is correct:
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
Then it looks like you've got a typo in your gem file. You've installed the gem, but it won't bundle with the app since you didn't spell rspec-rails correctly. Check your declarations in the gem file.
It is an annoying word to spell.
I noticed your :test group contains a typo: rpsec instead of rspec.

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