安裝ruby新版本(github上的rbenv文檔--)

來源:互聯網
上載者:User

標籤:


https://github.com/sstephenson/rbenv

  • Check out rbenv into ~/.rbenv.
    $ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
  • Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility.
    $ echo ‘export PATH="$HOME/.rbenv/bin:$PATH"‘ >> ~/.bash_profile

    Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.

    Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.

  • Add rbenv init to your shell to enable shims and autocompletion.
    $ echo ‘eval "$(rbenv init -)"‘ >> ~/.bash_profile

    Same as in previous step, use ~/.bashrc on Ubuntu, or ~/.zshrc for Zsh.

  • Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if rbenv was set up:
    $ type rbenv#=> "rbenv is a function"
  • (Optional) Install ruby-build, which provides the rbenv install command that simplifies the process ofinstalling new Ruby versions.

 

Upgrading

If you‘ve installed rbenv manually using git, you can upgrade your installation to the cutting-edge version at any time.

$ cd ~/.rbenv$ git pull

To use a specific release of rbenv, check out the corresponding tag:

$ cd ~/.rbenv$ git fetch$ git checkout v0.3.0--------------------------------------------

$rbenv install --list     如果發現沒有自己想要裝的版本
$cd ~/.rbenv
$git pull
$cd plugins
$cd ruby-build
$git pull
$rbenv install --list
$rbenv install 2.1.2

==========如果這時候下載不了====

查看https://github.com/sstephenson/ruby-build#readme

Package download caching

You can instruct ruby-build to keep a local cache of downloaded package files by setting theRUBY_BUILD_CACHE_PATH environment variable. When set, package files will be kept in this directory after the first successful download and reused by subsequent invocations of ruby-build and rbenv install.

The rbenv install command defaults this path to ~/.rbenv/cache, so in most cases you can enable download caching simply by creating that directory.

建立個cache檔案夾,手動下載安裝包

2001 cd ~/.rbenv/
2002 ll
2003 mkdir cache
2004 cd cha
2005 cd cache/
2006 wget http://ruby.taobao.org/mirrors/ruby/ruby-2.2.2.tar.gz
2007 cd 
2008 rbenv install 2.2.2 -v

=====================


$ruby -v
$rbenv global 2.1.2
$rbenv versions
還有一種方式是
$export RBENV_VERSION=2.1.2
但是這種方式只在當前終端視窗有效
$gem install rails
這時候會發現速度超級慢,
$gem list
$gem source -l
來到網頁看一下吧 ruby.taobao.org,接著按照網頁提示操作
$gem sources --remove http://rubygems.org/
....
$gem install rails

安裝ruby新版本(github上的rbenv文檔--)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.