简体   繁体   English

在没有RVM的情况下更改Ruby路径

[英]Change Ruby Path without RVM

I'm not in the position to use RVM because I'm working with a predefined OS and a proxy. 我无法使用RVM,因为我正在使用预定义的OS和代理。

I'm working on CentOS7 and my application uses ruby 2.3.1 . 我正在使用CentOS7,我的应用程序使用ruby 2.3.1 This comes pre-installed on this specific system. 它已预先安装在此特定系统上。 CentOS7 supports ruby up to 2.0.0 . CentOS7最多支持2.0.0 ruby。

My problem is when I install KDE for a shell it installs ruby 2.0.0 and overrides certain paths so when I use ruby -v I now use 2.0.0 which is not good! 我的问题是,当我为外壳安装KDE时,它将安装ruby 2.0.0并覆盖某些路径,因此当我使用ruby -v我现在使用2.0.0 ,这不好!

If I do which -a ruby I get 如果我这样做which -a ruby我得到的是which -a ruby

/usr/bin/ruby
/opt/rubies/ruby-2.3.1/bin/ruby

If I do echo $PATH I get 如果我echo $PATH我得到

/opt/rh/rh-postgresql95/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/rubies/ruby-2.3.1/bin:/usr/local/rvm/bin

The Ruby I want to use is installed in /opt/rubies/ruby-2.3.1/bin but /usr/bin comes before it. 我要使用的Ruby安装在/opt/rubies/ruby-2.3.1/bin/usr/bin位于它之前。 Is that the reason why CentOS7 is using that version of Ruby instead of the pre-installed Ruby 2.3.1 version in /opt/rubies/ruby-2.3.1/bin ? 这就是为什么CentOS7使用该版本的Ruby而不是/opt/rubies/ruby-2.3.1/bin中预先安装的Ruby 2.3.1版本的/opt/rubies/ruby-2.3.1/bin吗?

If so, how do I change the order of the path? 如果是这样,如何更改路径顺序?

The Ruby I want to use is installed in /opt/rubies/ruby-2.3.1/bin but /usr/bin comes before it. 我要使用的Ruby安装在/opt/rubies/ruby-2.3.1/bin中,但/ usr / bin位于它之前。 Is that the reason why CentOS7 is using that version of Ruby instead of the pre-installed Ruby 2.3.1 version in /opt/rubies/ruby-2.3.1/bin? 这是为什么CentOS7使用该版本的Ruby而不是/opt/rubies/ruby-2.3.1/bin中预先安装的Ruby 2.3.1版本的原因吗?

Yes, it is the reason. 是的,这就是原因。

how do I change the order of the path? 如何更改路径顺序?

You can redefine the $PATH in your ~/.bashrc . 您可以在~/.bashrc重新定义$PATH Just add this line at the bottom: 只需在底部添加以下行:

export PATH="/opt/rubies/ruby-2.3.1/bin:$PATH"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM