Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将ruby和rubygems移动到自定义路径中_Ruby_Rubygems_Gem_Bundler - Fatal编程技术网

将ruby和rubygems移动到自定义路径中

将ruby和rubygems移动到自定义路径中,ruby,rubygems,gem,bundler,Ruby,Rubygems,Gem,Bundler,我有一个本地ruby解释器,它是由第三方创建的,安装在/usr/lib/projectA/ruby/bin/ruby 现在,我想将整个文件夹结构复制到另一个具有相同结构的文件夹中:/usr/lib/projectB/ruby/bin/ruby 在我复制了文件之后,调用复制的ruby,例如 # /usr/lib/projectB/ruby/bin/ruby -v ruby 1.9.x 但是,当我跑步时,它似乎在工作 # /usr/lib/projectB/ruby/bin/ruby -e 'pu

我有一个本地ruby解释器,它是由第三方创建的,安装在
/usr/lib/projectA/ruby/bin/ruby

现在,我想将整个文件夹结构复制到另一个具有相同结构的文件夹中:
/usr/lib/projectB/ruby/bin/ruby

在我复制了文件之后,调用复制的ruby,例如

# /usr/lib/projectB/ruby/bin/ruby -v
ruby 1.9.x
但是,当我跑步时,它似乎在工作

# /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>'
现在,无法加载另一个文件,因此我假设还会有更多的文件

所以

  • 为我的新ruby设置新的rubygems基本路径的正确方法是什么
  • 为什么甚至调用
    put 1
    都会调用rubygems

  • p、 我不能使用rvm或类似的方法,因为我们需要使用ruby向用户部署整个zip包。

    您可以使用rvm,并通过
    rvm\u path
    参数在
    .rvmrc
    文件中设置路径。 如果路径正常,请再次检查您的
    ~/.bashrc
    ~/.bash\u配置文件

    另一个选项是使用ruby的
    $PATH
    $LD\u LIBRARY\u PATH
    并使用
    $GEM\u PATH
    ,它提供了可以找到GEM的位置(可能有多个)。 您可能需要使用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.
    

    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.