tags:

views:

672

answers:

2
$:.unshift File.join(File.dirname(__FILE__),\
'vendor','addressable-2.1.0','lib','addressable','uri')

Does the code above access a file that has this path:

'vendor/addressable-2.1.0/lib/addressable/uri'

I'm trying to vendor the addressable gem into a Sinatra app to deploy it to my hosting provider but I keep receiving:

"no such file to load -- addressable/uri"

after putting the 'unshift' line in config.ru.

+2  A: 

The above code adds the path "vendor/addressable-2.1.0/lib/addressable/uri" to the global variable used for looking up external files. The path will be relative to the directory that houses the file this code is placed in. So were {dir} is the directory config.ru is placed, it will add {dir}/vendor/addressable-2.1.0/lib/addressable/uri to the lookup path for includes.

Brandon Bodnár
A: 

What the line does is it puts the path 'vendor/addressable-2.1.0/lib/addressable/uri' (relative to the directory your ruby script is in) into the load path, which is the list of directories ruby looks through when looking for files you require.

By itself the line won't try to access any files.

sepp2k