markdown 从RVM切换到rbenv

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 从RVM切换到rbenv相关的知识,希望对你有一定的参考价值。

## Switch from RVM to rbenv:


##### Get Rid of RVM if it's installed: 
```rvm implode```

##### Cleanup your .bash_profile/.bashrc/.zshrc file to remove RVM from the path:

You should have something like this left from RVM.  Delete it from the file.
``[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"```

---


##### Ensure your homebrew is working properly and up to date:
```
brew doctor
brew update
```

---


##### Install Rbenv via homebrew: 
```
brew install rbenv
brew install ruby-build
```

##### Add ~/.rbenv/bin to your $PATH for access to the rbenv command-line utility:

Afterwards you'll still need to run `rbenv init`. You'll only ever have to do this once.

> (NOTE: Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.)

##### 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 by typing `rbenv` into the terminal.
You should see something like this:

```
rbenv 0.4.0
Usage: rbenv <command> [<args>]

Some useful rbenv commands are:
   commands    List all available rbenv commands
   local       Set or show the local application-specific Ruby version
   global      Set or show the global Ruby version
   shell       Set or show the shell-specific Ruby version
   install     Install a Ruby version using ruby-build
   uninstall   Uninstall a specific Ruby version
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List all Ruby versions available to rbenv
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/sstephenson/rbenv#readme
``` 
Yay, works!

---


### Using rbenv:

##### To see a list of available Ruby versions for install:
```
rbenv install -l
```

> PRO-TIP:  Don't see the ruby version listed you are looking for (aka specified in your gemfile?)?  Then you probably are due for a brew update!
`brew update` & `brew upgrade ruby-build`

##### Check the Ruby versions list again...
```
rbenv install -l
```

##### To install a ruby version:
```
rbenv install 2.3.0
```

##### Before you can bundle and install gems, add bundler:
```
gem install bundler
```

##### Then you can bundle & install all the gems in the gemfile!
```
cd your-project-folder
bundle install
```

##### Set a project specific (local) ruby version:
```
cd your-project-folder
rbenv local 2.3.0
```

---

Rbenv info: [https://github.com/rbenv/rbenv#installation](https://github.com/rbenv/rbenv#installation)

Removing RVM tips: [https://richonrails.com/articles/uninstalling-rvm](https://richonrails.com/articles/uninstalling-rvm)

以上是关于markdown 从RVM切换到rbenv的主要内容,如果未能解决你的问题,请参考以下文章

markdown 使用rbenv切换Ruby版本

RVM 和 rbenv 是如何工作的?

rbenv、rvm 和 chruby 有啥区别? [关闭]

为 Ruby on Rails 6 创建弹性 beanstalk 环境时遇到问题(rvm、rbenv、.ruby-version 问题)

如何为项目设置特定的 Ruby 版本(无 rvm 和 rbenv)

使用rbenv 进行ruby 多版本的管理