Skip to content

Instantly share code, notes, and snippets.

@iguoli
Last active July 17, 2018 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iguoli/cc1cbc254823c061d9ad8cdc71a4b1a7 to your computer and use it in GitHub Desktop.
Save iguoli/cc1cbc254823c061d9ad8cdc71a4b1a7 to your computer and use it in GitHub Desktop.
Linux下安装Ruby

Linux下安装Ruby

# Clone rbenv into ~/.rbenv
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv

# Optionally, try to compile dynamic bash extension to speed up rbenv. Don't worry if it fails; rbenv will still work normally
$ cd ~/.rbenv && src/configure && make -C src

# Add ~/.rbenv/bin to your $PATH
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc

# Set up rbenv in your shell
$ ~/.rbenv/bin/rbenv init

# Follow the printed instructions to set up rbenv shell integration, it looks like this:
$ echo 'eval "$(rbenv init -)"' >> ~/.zshrc

# Verify that rbenv is properly set up using this rbenv-doctor script:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
# As an rbenv plugin
$ mkdir -p "$(rbenv root)"/plugins
$ git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
# list all available versions
$ rbenv install -l

# install a Ruby version
$ rbenv install 2.5.1

# list all installed Ruby versions
$ rbenv versions

# list current Ruby version
$ rbenv version

# set global version of Ruby to be used in all shells by writing the version name to the `~/.rbenv/version` file
$ rbenv global 2.5.1

# reports the currently configured global version
$ rbenv global

# set a local application-specific Ruby version by writing the version name to a .ruby-version file in the current directory
$ rbenv local 2.5.1

# set a shell-specific Ruby version
$ rbenv shell 2.5.1

# install Ruby gems
$ gem install bundler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment