rvm 安装

https://rvm.beginrescueend.com/rvm/install/


Installing RVM

There are two fundamentally different ways to install and configure RVM.

  • Single-User installations - (For an isolated install within a user's $HOME)
  • Multi-User installations (For server administrators - For an installation usable by all users on the system - Please note that Single-User supercedes Multi-User. This also used to be called the System-Wide Install)

The system-wide script is no longer available, and any tutorials referencing it will no longer work correctly. Multi-User is the System-Wide install. The only supported install type for multiple users is the Multi-User install referenced below.

Note that that any outside tutorials are NOT supported whether they work or not. Tutorials are great, however we have spent massive amounts of man hours debugging the installation process. Please use the install process(es) from this site only, as this is the only supported installation types and methods.

For most purposes, the recommended installation method is Single-User, which is a self-contained RVM installation in a user's home directory.

To update an existing RVM installation

It is safe to simply re-run the installation script again, or you can follow the upgrading docs.

Installation

I recommend you read the installation script yourself. This will give you a chance to understand what it is doing before installing, and allow you to feel more comfortable running it if you do so.

1. Download and run the RVM installation script

Installing the latest release version in git:
user$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

For a Multi-User install you would execute the following:

user$ sudo bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
     Note: All multi-user install instructions must be prefixed with the 'sudo' command.
Installing a specific version:
user$ curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer --version latest

For a Multi-User install you would do:

user$ curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer -o rvm-installer ; chmod +x rvm-installer ; sudo ./rvm-installer --version latest
Single-User Install Location: ~/.rvm/

If the install script is run as a standard, non-root user, RVM will install into the current users's home directory.

Multi-User Install Location: /usr/local/rvm

If the install script is run prefixed with sudo, RVM will automatically install into /usr/local/rvm Please see the troubleshooting page for an important note regarding Multi-User Installs.

If the rvm install script does nothing or complains about certificates you can bypass this by adding a '-k' switch to the curl command:

For Single-User installs

user$ bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

Please see the FAQ page for an important note regarding root only installs

For a Multi-User install you would do:

user$ sudo bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

2. Load RVM into your shell sessions as a function

Throughout these instructions, you may replace .bash_profile with the appropriate startup script for your bash-compatible shell. For other shells you may need to modify these commands. Zsh should be able to use these commands unmodified.
Single-User:

Load RVM by appending the rvm function sourcing to your .bash_profile:

user$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
Multi-User:

The rvm function will be automatically configured for every user on the system if you install as root. This is accomplished by loading /etc/profile.d/rvm.sh on login. Most Linux distributions default to parsing /etc/profile which contains the logic to load all files residing in the /etc/profile.d/ directory. Once you have added the users you want to be able to use RVM to the rvm group, those users MUST log out and back in to gain rvm group membership because group memberships are only evaluated by the operating system at initial login time.

3. Reload shell configuration & test

Close out your current shell or terminal session and open a new one. You may attempt reloading your .bash_profile with the following command:

user$ source .bash_profile

However, closing out your current shell or terminal and opening a new one is the preferred way for initial installations.

If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output 'rvm is a function' as shown below.

user$ type rvm | head -1
rvm is a function

Finally, see if there are any dependency requirements for your operating system by running:

user$ rvm requirements

NOTE: Whenever you upgrade RVM in the future, you should always run 'rvm notes' and 'rvm requirements' as this is usually where you will find details on any major changes and/or additional requirements to ensure your installation stays working. Also, you should also run the above command on any fresh installs. This is where all your additionals will be noted making it an extremely important stop on your way to RVM bliss!

Congratulations! You have successfully installed RVM.

Try out your new RVM installation

Below are some examples of how to install and use a Ruby under RVM.

Display a list of all "known" rubies. NOTE: RVM can install many more Rubies not listed.

user$ rvm list known
# MRI Rubies
...
[ruby-]1.8.7[-p334]
[ruby-]1.8.7-head
...
[ruby-]1.9.2[-p180]
[ruby-]1.9.2-head
ruby-head

# JRuby
jruby-1.2.0

...

Install a version of Ruby (eg 1.9.2):

user$ rvm install 1.9.2
Installing Ruby from source to: /Users/user/.rvm/rubies/ruby-1.9.2-p180, this may take a while depending on your cpu(s)...

ruby-1.9.2-p180 - #fetching
ruby-1.9.2-p180 - #downloading ruby-1.9.2-p180, this may take a while depending on your connection...
...
ruby-1.9.2-p180 - #extracting ruby-1.9.2-p180 to /Users/user/.rvm/src/ruby-1.9.2-p180
ruby-1.9.2-p180 - #extracted to /Users/user/.rvm/src/ruby-1.9.2-p180
ruby-1.9.2-p180 - #configuring
ruby-1.9.2-p180 - #compiling
ruby-1.9.2-p180 - #installing
...
Install of ruby-1.9.2-p180 - #complete

Use the newly installed Ruby:

user$ rvm use 1.9.2
Using /Users/user/.rvm/gems/ruby-1.9.2-p180

Check this worked correctly:

user$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [i386-darwin9.8.0]

user$ which ruby
Using /Users/user/.rvm/gems/ruby-1.9.2-p180/bin/ruby

Optionally, you can set a version of Ruby to use as the default for new shells. Note that this overrides the 'system' ruby:

user$ rvm use 1.9.2 --default

Enjoy using RVM!

Where to now?

If you are new to RVM I recommend that you read the basics page. At the end of the basics page there are further links for getting started.

Troubleshooting Your Install

  • If you open a new shell and running:

    $ type rvm | head -1

    does not show "rvm is a function", RVM isn't being sourced correctly.

  • Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.

  • If you are using GNOME on Red Hat, CentOS or Fedora, ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.

Example RVM bootstrap script

The following script will boostrap git + RVM, assuming that you have curl and sudo installed. The last line of the script will also install several commonly used Rubies for you.

#!/usr/bin/env bash

# Install git
bash < <( curl -s https://rvm.beginrescueend.com/install/git )

# Install RVM
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

# Install some Rubies
source "$HOME/.rvm/scripts/rvm"
rvm install 1.9.2,rbx,jruby

For a Multi-User install you would use:

#!/usr/bin/env bash

# Install git
sudo bash < <( curl -s https://rvm.beginrescueend.com/install/git )

# Install RVM
sudo bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

# Install some Rubies
source "/usr/local/rvm/scripts/rvm"
rvm install 1.9.2,rbx,jruby

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值