I
Intransition
I recently came across two different programs that had this line in a
bin/ executable:
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../
lib"))
This stuff makes me sad. The use of RubyGems is masking some bad
practices here. The above code would not work with a traditional site
installation.
I imagine this sort of thing has probably trickled down form Rails,
where programmers are accustom to deploying apps rather than releasing
them.
So here are the general rules (that I can think of off the top of my
head):
* Don't mess with the $LOAD_PATH. PERIOD.
* Use relative lookup only when you must, eg. using bundled HTML
templates.
* Any relative paths you do use must remain within the confines of
their main directory (eg. lib/)
* Don't use a relative lookup for any ,rb or .so/.dll loading. PERIOD.
* Oh, and it should never need to necessary to require 'rubygems'.
These rules do not apply to building, eg. your Rakefile, running tests
and such. But try to follow them as much as possible anyway.
~Trans
bin/ executable:
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../
lib"))
This stuff makes me sad. The use of RubyGems is masking some bad
practices here. The above code would not work with a traditional site
installation.
I imagine this sort of thing has probably trickled down form Rails,
where programmers are accustom to deploying apps rather than releasing
them.
So here are the general rules (that I can think of off the top of my
head):
* Don't mess with the $LOAD_PATH. PERIOD.
* Use relative lookup only when you must, eg. using bundled HTML
templates.
* Any relative paths you do use must remain within the confines of
their main directory (eg. lib/)
* Don't use a relative lookup for any ,rb or .so/.dll loading. PERIOD.
* Oh, and it should never need to necessary to require 'rubygems'.
These rules do not apply to building, eg. your Rakefile, running tests
and such. But try to follow them as much as possible anyway.
~Trans