no such file to load only in ruby 1.9.2

J

james b.

I am making a gem and i have three files:

gem_name.rb
gem_name/
version.rb
server.rb

in gem_name.rb it requires the other two files but for some reason on
ruby 1.9.2 i can't find server but on 1.8.7 it can. I am using rvm and
had a previously installed gem of the same name from when i was testing
things so i thought that might be the problem so i reinstalled ruby
1.9.2 on rvm but the problem still persists.

Any help would be much appreciated.

Thanks, James.
 
P

Phillip Gawlowski

I am making a gem and i have three files:

gem_name.rb
gem_name/
=A0 =A0version.rb
=A0 =A0server.rb

in gem_name.rb it requires the other two files but for some reason on
ruby 1.9.2 i can't find server but on 1.8.7 it can. I am using rvm and
had a previously installed gem of the same name from when i was testing
things so i thought that might be the problem so i reinstalled ruby
1.9.2 on rvm but the problem still persists.

Any help would be much appreciated.

Did you try
require_relative 'server'

or alternatively

require './server'

yet?

--=20
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
R

Ryan Davis

I am making a gem and i have three files:
=20
gem_name.rb
gem_name/
version.rb
server.rb
=20
in gem_name.rb it requires the other two files but for some reason on
ruby 1.9.2 i can't find server but on 1.8.7 it can. I am using rvm and
had a previously installed gem of the same name from when i was = testing
things so i thought that might be the problem so i reinstalled ruby
1.9.2 on rvm but the problem still persists.

Put everything in 'lib'. Put the tests (that you need to write) in =
'test'.

lib/gem_name.rb should require like so:

require "gem_name/server"

when you run your tests (preferably via rake) make sure that "lib" is in =
your load path.=20

ruby -Ilib test/gem_name/test_server.rb

and when you package this up as a gem, the "lib" dir should be in your =
gemspec's lib path.
 
J

james b.

Thanks for the replies

I am currently using
require "gem_name/server"

I tried the other two suggestions but still no success

gem_name.rb is in the lib directory already and i'm not (gasp) using any
tests. The problem occurs when i install the gem using rake install
provided to me by bundler. I hope that it will work if you install it
through rubygems but i somehow doubt that.

I know i really should have tests so i guess now is as good a time as
ever to start so if you can suggest a test framework to use that would
be great.

Thanks
 
R

Ryan Davis

Thanks for the replies
=20
I am currently using
require "gem_name/server"
=20
I tried the other two suggestions but still no success

The last part you need to know is that 1.9 dropped '.' from the default =
load path. that's why I say put it in lib and make sure lib is in your =
path on BOTH 1.8 and 1.9.=20
gem_name.rb is in the lib directory already and i'm not (gasp) using = any
tests. The problem occurs when i install the gem using rake install
provided to me by bundler. I hope that it will work if you install it
through rubygems but i somehow doubt that.
=20
I know i really should have tests so i guess now is as good a time as
ever to start so if you can suggest a test framework to use that would
be great.

I use minitest for nearly everything. Ships with 1.9. I use Hoe with my =
projects so it's all integrated and happy.=
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top