Take the 2-minute tour ×

I'm doing the Ruby Koans tutorial, using notepad++.

The about_triangle_project.rb can't seem to load the triangle.rb file.

no such file to load -- triangle.rb <LoadError>
from <internal:lib/rubygems/custom_require>:29:in 'require'
from about_triangle_project.rb:4: in '<main>'

However I don't think I've altered the files. (I tried to fix it but always undid these when they didn't work)... Here's the code in about_triangle_project.rb

require File.expand_path(File.dirname(__FILE__) + '/edgecase')

require 'triangle.rb' # this is line 4

class AboutTriangleProject < EdgeCase::Koan
  def test_equilateral_triangles_have_equal_sides
    assert_equal :equilateral, triangle(2, 2, 2)
    assert_equal :equilateral, triangle(10, 10, 10)

I have tried require 'triangle', that didn't work. I tried using an absolute pathname, that didn't work.

and the triangle.rb file is in the same directory, unaltered, with comments and just this:

def triangle(a,b,c)
class TriangleError < StandardError

The triangle.rb file does exist in the same directory, so why can't it be found? I hope I'm not missing something glaringly obvious!

share|improve this question

2 Answers 2

It appears that on Windows, adding the current directory to the load path doesn't quite work right. Substituting require 'triangle.rb' for require_relative 'triangle.rb' should work, but is a bit of a hack. I don't use Windows, so I'm not sure what the proper solution would be.

share|improve this answer

I'd definitely look into obtaining a version of Sublime Text Editor, it makes things much cleaner and you can actually open folders in it.

And it looks like your pathing is wrong, I would say make sure that the address of triangle.rb is correct in your code.

Mine looks something more like this

require File.expand_path(File.dirname(FILE) + '/neo')

#You need to write the triangle method in the file 'triangle.rb'

require './triangle'

share|improve this answer

Your Answer


