Adding load_path

Hi all:

In Ubuntu, I have to install a program into my home directory because I do
not have the privilege to install in the usr/local/bin and usr/local/lib
directory.

~/OT/usr/local/lib/site_ruby/*.so # many so files
~/OT/usr/local/lib/site_ruby/1.8/
~/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/*.so #
includes many .so files
~/OT/usr/local/lib/site_ruby/1.8/OT.rb
   # load a number of *.so files located in "x86_64-linux/"
~/OT/usr/local/lib/site_ruby/1.8/OT/RT/RT.rb #
RT.rb has " require 'OT' "

There are load errors in RT.rb and OT.rb

It works perfectly if I put in the /usr/local directory instead of home but
I do not have the permission.

I have add system search path ~/OT/usr/local/lib/site_ruby/1.8/
and ~/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/ but it still does not
work.

So my question is that how to configure to make the ruby or system search
the lib and .rb files? I use tcsh.

Thanks,

JH

Hello,

Why don't you try RVM. It will save you from dealing with many circumstances that need 'root privs' and deals with all the paths and snags that you're trying to solve.

https://rvm.io/

···

On 18 Νοε 2012, at 08:11 , Jia Hu <hujia06@gmail.com> wrote:

Hi all:

In Ubuntu, I have to install a program into my home directory because I do not have the privilege to install in the usr/local/bin and usr/local/lib directory.

~/OT/usr/local/lib/site_ruby/*.so # many so files
~/OT/usr/local/lib/site_ruby/1.8/
~/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/*.so # includes many .so files
~/OT/usr/local/lib/site_ruby/1.8/OT.rb # load a number of *.so files located in "x86_64-linux/"
~/OT/usr/local/lib/site_ruby/1.8/OT/RT/RT.rb # RT.rb has " require 'OT' "

There are load errors in RT.rb and OT.rb

It works perfectly if I put in the /usr/local directory instead of home but I do not have the permission.

I have add system search path ~/OT/usr/local/lib/site_ruby/1.8/ and ~/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/ but it still does not work.

So my question is that how to configure to make the ruby or system search the lib and .rb files? I use tcsh.

Thanks,

JH

Panagiotis (atmosx) Atmatzidis

email: atma@convalesco.org
URL: http://www.convalesco.org
GnuPG ID: 0xE736C6A0
gpg --keyserver x-hkp://pgp.mit.edu --recv-keys 0xE736C6A0
--
The wise man said: "Never argue with an idiot. They bring you down to their level and beat you with experience."

Best way to do this is add them at execute time with $LOAD_PATH

I do this in your ruby script before the require.

$LOAD_PATH.insert(0, '/home/username/apps/app1/lib')
$LOAD_PATH.insert(0, '/home/username/apps/app2/lib')
$LOAD_PATH.insert(0, '/home/username/apps/app3/lib')

So what you pointed out I would think you would want to do, I broke it
down into a few extra lines, just to keep a "one thing per line example"

homeDir = "#{ENV['HOME']}"
directoryOne = "#{homeDir}/OT/usr/local/lib/site_ruby/1.8/"
directoryTwo = "#{homeDir}/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/"

$LOAD_PATH.insert(0, directoryOne)
$LOAD_PATH.insert(0, directoryTwo)

···

--
Posted via http://www.ruby-forum.com/.

Quoting Grant Schoep (lists@ruby-forum.com):

Best way to do this is add them at execute time with $LOAD_PATH

You can also include the libraries in the RUBYLIB shell variable. The
content of RUBYLIB is prepended to the default list of paths:

$ export RUBYLIB=/a/b:/c/d/e:/f/g/h/i
$ irb
irb(main):001:0> $LOAD_PATH
=> ["/a/b", "/c/d/e", "/f/g/h/i", "/usr/local/lib/ruby/site_ruby/2.0.0", "/usr/local/lib/ruby/site_ruby/2.0.0/x86_64-linux", "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/vendor_ruby/2.0.0", "/usr/local/lib/ruby/vendor_ruby/2.0.0/x86_64-linux", "/usr/local/lib/ruby/vendor_ruby", "/usr/local/lib/ruby/2.0.0", "/usr/local/lib/ruby/2.0.0/x86_64-linux"]
irb(main):002:0>

If you want all your system's users to use special paths, you can add your
export command in the /etc/profile system file.

Carlo

···

Subject: Re: adding load_path
  Date: Mon 19 Nov 12 11:08:46AM +0900

--
  * Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe
  * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)

Best way to do this is add them at execute time with $LOAD_PATH

You can also include the libraries in the RUBYLIB shell variable. The
content of RUBYLIB is prepended to the default list of paths:

$ export RUBYLIB=/a/b:/c/d/e:/f/g/h/i
$ irb
irb(main):001:0> $LOAD_PATH

The original request mentioned they were using tcsh. For tcsh do
if you don't have RUBYLIB env variable set

setenv RUBYLIB /some/install/path/lib

if you already have RUBYLIB set

setenv RUBYLIB /some/install/path/lib:#{RUBYLIB}

Ruby will grab what is in your RUBYLIB variable, and prepend them.

I'm sure since the author wasn't able to install libraries to the
machine, they would also no be able to edit the /etc/profile(only used
by bash by the way)

···

--
Posted via http://www.ruby-forum.com/\.

Thank all of you. I add load path:
$LOAD_PATH.insert(0, "/my/path1")
$LOAD_PATH.insert(0, "/my/path2")

Besides this, I also need to add:
setenv $LD_LIBRARY_PATH ~/OT/usr/local/lib/site_ruby/1.8/x86_64-linux/:
~/OT/usr/local/lib/

Then it works. The shared library .so call other .so files. So I have to
use $LD_LIBRARY_PATH

Thanks,

···

On Mon, Nov 19, 2012 at 8:25 PM, Grant Schoep <lists@ruby-forum.com> wrote:

>> Best way to do this is add them at execute time with $LOAD_PATH
>
> You can also include the libraries in the RUBYLIB shell variable. The
> content of RUBYLIB is prepended to the default list of paths:
>
> $ export RUBYLIB=/a/b:/c/d/e:/f/g/h/i
> $ irb
> irb(main):001:0> $LOAD_PATH

The original request mentioned they were using tcsh. For tcsh do
if you don't have RUBYLIB env variable set

setenv RUBYLIB /some/install/path/lib

if you already have RUBYLIB set

setenv RUBYLIB /some/install/path/lib:#{RUBYLIB}

Ruby will grab what is in your RUBYLIB variable, and prepend them.

I'm sure since the author wasn't able to install libraries to the
machine, they would also no be able to edit the /etc/profile(only used
by bash by the way)

--
Posted via http://www.ruby-forum.com/\.