From: David Alan Black Date: 2002-01-15T12:35:48+09:00 Subject: Re: require and file extensions Hello -- On Tue, 15 Jan 2002, Phil Tomson wrote: > I've noticed that sometimes if I say: > require "somefile.rb" > > I'll get a message about somefile.rb not being found (even thought it's > there). If I change it to: > require "somefile" > > All is well. > > Also it seems like you can have the file extenstion '.rb' if you use > single ticks, like: > > require 'somefile.rb' > And all is well... > > So, is the formal rule (and I didn't see anything in the FAQ or books) > that if you use double qoutes (") that it tries to append '.rb' to the > filename and if you use single quotes (') that it won't try to append? > (And since it appends '.rb' if you use the full filename including the .rb > extention it actually looks for somefile.rb.rb if you specify require > "somefile.rb" ?) There shouldn't be any difference between the '' and the "" syntax. Can you provide an entire (non-)working example? Meanwhile, here's the ri listing for require: -------------------------------------------------------- Kernel::require require( aString ) -> true or false ------------------------------------------------------------------------ Ruby tries to load the library named aString, returning true if successful. If the filename does not resolve to an absolute path, it will be searched for in the directories listed in $:. If the file has the extension ``.rb'', it is loaded as a source file; if the extension is ``.so'', ``.o'', or ``.dll'',[Or whatever the default shared library extension is on the current platform.] Ruby loads the shared library as a Ruby extension. Otherwise, Ruby tries adding ``.rb'', ``.so'', and so on to the name. The name of the loaded feature is added to the array in $". A feature will not be loaded if it already appears in $". require returns true if the feature was successfully loaded. require "my-library.rb" require "db-driver" David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav