3

I have a local ruby interpreter created a third party which is installed under /usr/lib/projectA/ruby/bin/ruby

Now, I want to copy the whole folder strcuture into another folder with the same structure: /usr/lib/projectB/ruby/bin/ruby

After I copied the files, and call the copied ruby, e.g.

# /usr/lib/projectB/ruby/bin/ruby -v
ruby 1.9.x

Seems to be working, however, when I run

# /usr/lib/projectB/ruby/bin/ruby -e 'puts 1'
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'

Seems it can't find the rubygems, so I add the path

# /usr/lib/projectB/ruby/bin/ruby -e 'puts 1' -I '/usr/lib/projectB/ruby/lib/'
/usr/lib/projectB/ruby/lib/ruby/1.9.1/rubygems.rb:31:in `require': cannot load such file -- rbconfig (LoadError)

Now, another files cannot be loaded, so I assume more to come..

So

  1. What is the correct method to set the new rubygems base path for my new ruby?
  2. Why even calling puts 1 will invoke the rubygems?

p.s. I can't use rvm or similar approach as we need to deploy the whole zip package with the ruby to our user.

4

1 回答 1

0

您可以使用 RVM 并.rvmrc 通过rvm_path参数设置文件中的路径。还要仔细检查您的~/.bashrc~/.bash_profile路径是否正常。

其他选择是使用$PATH$LD_LIBRARY_PATH使用 ruby​​ 并使用$GEM_PATH它提供可以找到宝石的位置(可能有几个)。您可能需要使用 Ruby 的环境变量:

RUBYOPT     Additional command-line options to Ruby; examined after real command-line options are parsed ($SAFE must be 0).
RUBYLIB     Additional search path for Ruby programs ($SAFE must be 0).
RUBYPATH    With -S option, search path for Ruby programs (defaults to PATH).
RUBYSHELL   Shell to use when spawning a process; if not set, will also check SHELL or COMSPEC.
DLN_LIBRARY_PATH    Search path for dynamically loaded modules.
RUBYLIB_PREFIX  (Windows only) Mangle the RUBYLIB search path by adding this prefix to each component.

这里

于 2013-12-27T08:05:37.053 回答