Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / "require 'player' " in my_game.rb
- - By smilinpiggy Date 2013-01-16 19:37
Hi, I'm a newbie to Ruby ... thanks in advance for any help :)

As I was following the beginner video tutorial one of the first steps is add to my_game.rb...

require 'player'

I did that and got an error.

/usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot load such file -- player (LoadError)
  from /usr/local/rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in
  from my_game.rb:3:in `<main>'

Finally got it to work by doing this that I read in another forum:

require './player'

Can someone please explain why that works?
Parent - By Dahrkael Date 2013-01-16 22:46
because starting from ruby 1.9.1 they removed the current directory from the array with the paths ( $: ).
an easy fix is to put this at the beginning
$: << "."
Parent - By jlnr (dev) Date 2013-01-17 04:32
If you only ever want to use Ruby 1.9.2 or above, you should use this instead:

require_relative 'player'

Ohmygod there is a video tutorial? :D I should Google gosu more often.
Up Topic Gosu / Gosu Exchange / "require 'player' " in my_game.rb

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill