From: pere.noel@... (=?ISO-8859-1?Q?Une_b=E9vue?=) Date: 2006-10-01T17:55:06+09:00 Subject: Re: getting the name of the script in use MonkeeSage wrote: > Two ways: > > 1) Copy direct.rb in the ruby lib / site_lib directory. You can see > where they are like this: > > require 'rbconfig' > puts Config::CONFIG['rubylibdir'] > puts Config::CONFIG['sitelibdir'] > > It is conventional (and easier to maintain) to put user scripts into > site_lib. > > OR > > 2) Add something like this to every script where you want to require > direct.rb: > > # $: is an alias for $LOAD_PATH > $: << '/some/dir' unless $:.include?('/some/dir') > require 'direct' may be their is a third way (using symlinks) ? not working at the time being it seems ruby isn't following symlinks i did a : ~%> sudo mkdir /opt/local/lib/ruby/site_ruby/1.8/yt and then : ~%> sudo ln -s direct.rb /opt/local/lib/ruby/site_ruby/1.8/yt/direct testing this : --- direct_test.rb ----------------------------------------------------- require 'yt/direct' puts "$basename = #{$basename}" ### line 3 ### ------------------------------------------------------------------------ i get : > direct_test.rb /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- yt/direct (LoadError) from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /Users/yvon/bin/direct_test.rb:3 ~/bin/rb%> the path is correct because using : --- ruby_libs_dir.rb --------------------------------------------------- #!/usr/bin/env ruby -w require 'rbconfig' puts Config::CONFIG['rubylibdir'] puts Config::CONFIG['sitelibdir'] ------------------------------------------------------------------------ i get : ~b%> ruby_libs_dir.rb /opt/local/lib/ruby/1.8 /opt/local/lib/ruby/site_ruby/1.8 then i must conclude ruby isn't following symlinks (?) then no third solution. the reason, for me, using this kind of solution it's because i have two installed ruby (apart from the one installed by default by Apple) : one in /opt/local... (darwinports) another installed in my HOME fo JRuby then , i'd like avoiding copying scripts in different locations. -- une b�vue