Help with LOAD_PATH when building from source on Mac OSX Lion

Hi all,

I’ve successfully built ruby (1.9.2-p290) from source on Mac OSX Lion
but I’m having problems with LOAD_PATH - basically it can’t find any
standard library files or gem files.

The load paths are :

/usr/local/lib/ruby/site_ruby/1.9.1
/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.1.0
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.9.1
/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.1.0
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.9.1
/usr/local/lib/ruby/1.9.1/x86_64-darwin11.1.0

The problem is that I want my ruby distro in a subversion repository in
~/buildtools/ruby/1.9.2. Is there any way I can get the load paths to be
relative? The buildtools repository is bootstrapped into different user
folders depending on user. I’ve fiddled a bit with makefiles but have
not been able to get the load paths to change. I am new to Macs and unix
so its probably something really obvious.

Of course I can manually set up all the paths with -I on the command
line but I wondered whether there was a more elegant method.

Cheers,
James

Why not pass the --prefix to configure when compiling?

./configure --prefix=~/buildtools/ruby/1.9.2

On Thu, Sep 8, 2011 at 2:06 PM, James F.
[email protected] wrote:

On 8 Sep 2011, at 12:23, Marc H. wrote:

Why not pass the --prefix to configure when compiling?

./configure --prefix=~/buildtools/ruby/1.9.2

Thanks, I wasn’t sure how to do that. It required an absolute path but
/Users/~/buildtools/ruby/1.9.2

You could also do

./configure “–prefix=${HOME}/buildtools/ruby/1.9.2”

assuming your shell expands ~ to the home directory.

did the trick and it can now load standard library files. Still having issues
with gems but I am unblocked for the moment so thanks!

I must say I’m surprised ruby doesn’t set up its default paths relative to the
ruby executable to prevent hard coding of location - means that we have to
maintain a company standard folder (there are other folders before build tools
that I didn’t mention). Not a huge deal though.

Well, both approaches have pros and cons. If you create a symlink to
the ruby executable from another directory then relative paths won’t
work. And since usually the installation is done once on a system and
not changed there is really no point in having relative paths. They
might also open security holes. All in all to me it seems the
approach taken is reasonable.

Kind regards

robert

On 8 Sep 2011, at 14:11, Robert K. wrote:

Well, both approaches have pros and cons. If you create a symlink to

remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Updating thread with the solution: when building ruby from source
specify --enable-load-relative when invoking configure. This makes the
distro relocatable - default load paths are then correct wherever the
distro is placed.

On 8 Sep 2011, at 12:23, Marc H. wrote:

Why not pass the --prefix to configure when compiling?

./configure --prefix=~/buildtools/ruby/1.9.2


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

Thanks, I wasn’t sure how to do that. It required an absolute path but
/Users/~/buildtools/ruby/1.9.2 did the trick and it can now load
standard library files. Still having issues with gems but I am unblocked
for the moment so thanks!

I must say I’m surprised ruby doesn’t set up its default paths relative
to the ruby executable to prevent hard coding of location - means that
we have to maintain a company standard folder (there are other folders
before build tools that I didn’t mention). Not a huge deal though.

Thanks again!

James