Ruby1.9.2 looking for Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:312

Hi

I have just started learning ruby and Im using ruby 1.9.2p0 (2010-08-18
revision 29036) [x86_64-darwin10.5.0].

Im trying to run a program from a book for CSV reader and when I try to
run it (using csv file as input) i get error from CSV library which is
under 1.8. And Im not sure if its correct…

Can someone please help

Thanks
guru

Processing sample.csv
./csv_reader.rb:14:in read_in_csv_data': uninitialized constant CsvReader::BooksInStock (NameError) from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:312:inopen_reader’
from
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:532:in
parse' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:560:ineach’
from
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:531:in
parse' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:311:inopen_reader’
from
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:94:in
foreach' from ./csv_reader.rb:13:inread_in_csv_data’
from ./stock_stats.rb:12
from ./stock_stats.rb:10:in `each’
from ./stock_stats.rb:10

i came across this forum Uninitialized constant CSV::Reader - Ruby - Ruby-Forum but i
still dont get what I have to use. Also I thought it might help to
provide my code here

#!/usr/bin/ruby
require ‘csv’
require ‘books_v2’
#require_relative ‘books_v2’

class CsvReader
def initialize
@books_in_stock = []
end

def read_in_csv_data(cvs_file_name)
CSV.foreach( cvs_file_name, :headers => true ) do |row|
@books_in_stock << BooksInStock.new(row[“ISBN”], row[“Amount”])
end
end

def total_value_in_stock
sum = 0.0
@books_in_stock.each {|book| sum += book.price}
sum
end
end

And I get error @ line “@book_in_stock<<…”

On Dec 12, 2010, at 9:20 PM, Guru I. wrote:

I have just started learning ruby and Im using ruby 1.9.2p0 (2010-08-18
revision 29036) [x86_64-darwin10.5.0].

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:312:in

`open_reader’
from

Something has gotten confused with your Ruby install, because you
mention version 1.9, but the code is trying to load a 1.8 library.

RVM is probably the best way to manage your Ruby installs on Mac OS X,
so I recommend you try that:

http://rvm.beginrescueend.com/

Hope that helps.

James Edward G. II

Sorry I just cant find the solution and when i checked my ruby
installation 1.9.2 …

its in /Users/XXXXX/.rvm/bin

XXXX - my home directory

but Why its looking for library under /System/Library/Frameworks…path?

please ignore my last post as i did not realize it found a reply. I will
look for rvm and get back

thanks
guru