[英]Ruby version not in ruby-build list for rbenv
I'm using Rails 4.2 and wanted to update my Ruby version as well with rbenv. 我正在使用Rails 4.2,也想使用rbenv更新我的Ruby版本。
I used Homebrew to install ruby-build and no matter how many times I try to update via brew
, Ruby version 2.1.3 won't show when I run rbenv install --list
. 我使用Homebrew安装ruby-build,无论我尝试通过
brew
更新多少次,运行rbenv install --list
时都不会显示Ruby 2.1.3版本。
Usually, follow these steps to install a new Ruby version with rbenv
: 通常,请按照以下步骤使用
rbenv
安装新的Ruby版本:
$ brew update
$ brew upgrade ruby-build
$ brew upgrade rbenv
Check which versions are available after updating: 更新后检查哪些版本可用:
$ ruby-build --definitions
Install a specific version (for example 2.1.3
) with: 使用以下命令安装特定版本(例如
2.1.3
):
$ rbenv install 2.1.3
Or if you are interested into improved support for UTF8 characters in the irb
console: 或者,如果您对
irb
控制台中对UTF8字符的改进支持感兴趣:
$ RUBY_CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.1.3
After these steps I usually set the newest version as my global default: 完成这些步骤之后,我通常将最新版本设置为全局默认值:
$ rbenv global 2.1.3
The recommended installation from ( https://github.com/sstephenson/ruby-build ) states that you should install ruby-build as an rbenv plug-in. ( https://github.com/sstephenson/ruby-build )的推荐安装指出您应该将ruby-build作为rbenv插件安装。
brew uninstall ruby-build
) brew uninstall ruby-build
( brew uninstall ruby-build
) git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
Now, when I run rbenv install --list
, I see Ruby 2.1.3. 现在,当我运行
rbenv install --list
,我看到了Ruby 2.1.3。 A quick installation of: rbenv install 2.1.3
and I am now free to use 2.1.3 where I like. 快速安装:
rbenv install 2.1.3
,现在我可以在喜欢的地方随意使用2.1.3了。 This also worked for my teammate. 这也为我的队友工作。
If you installed rbenv and ruby-build with homebrew and when you do echo $(rbenv root)
, you get /usr/local/var/rbenv
instead of /Users/<username>/.rbenv
, here is how to fix the issue. 如果您使用Homebrew安装了rbenv和ruby-build并且
echo $(rbenv root)
,则得到/usr/local/var/rbenv
而不是/Users/<username>/.rbenv
,这是解决问题的方法。
When you install rbenv with homebrew, homebrew says: 当使用homebrew安装rbenv时,homebrew会说:
To use Homebrew's directories rather than ~/.rbenv add to your profile:
export RBENV_ROOT=/usr/local/var/rbenv
Don't do that. 不要那样做 Remove that line from your profile.
从您的个人资料中删除该行。 Make sure you refresh your terminal after.
确保之后刷新终端。
Then remove any signs of rbenv in the /usr/local/var directory: 然后在/ usr / local / var目录中除去rbenv的所有迹象:
sudo rm -r /usr/local/var/rbenv
Now when I do echo $(rbenv root)
I get /Users/<username>/.rbenv
instead of /usr/local/var/rbenv
. 现在当我
echo $(rbenv root)
我得到/usr/local/var/rbenv
echo $(rbenv root)
/Users/<username>/.rbenv
而不是/usr/local/var/rbenv
。
That fixed it for me. 这为我解决了。
请通过brew upgrade ruby-build
更新,然后您应该在rbenv install --list
看到2.1.3
。
You need to update ruby build. 您需要更新ruby版本。 After update you can install all current suported versions.
更新后,您可以安装所有当前支持的版本。
If you using rbenv installed via git use 如果您使用通过git安装的rbenv,请使用
cd "$(rbenv root)"/plugins/ruby-build && git pull
Or via home brew 或通过家庭酿造
$ brew upgrade ruby-build
$ brew upgrade rbenv
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.