> For the complete documentation index, see [llms.txt](https://huang-jason.gitbook.io/ruby-rails-syntax/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://huang-jason.gitbook.io/ruby-rails-syntax/rvm.md).

# rvm / ENV

## RVM - ruby version manager

easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.

<https://stackoverflow.com/questions/9394338/how-do-rvm-and-rbenv-actually-work>

Short explanation: rbenv works by hooking into your environment's PATH.

First, rbenv creates shims for all the commands (ruby, irb, rake, gem and so on) across all your installed versions of Ruby.

These shims live in a single directory (\~/.rbenv/shims by default). To use rbenv, you need only add the shims directory to the front of your PATH:

export PATH="$HOME/.rbenv/shims:$PATH"

Then any time you run ruby from the command line, or run a script whose shebang reads #!/usr/bin/env ruby, your operating system will find \~/.rbenv/shims/ruby first and run it instead of any other ruby executable you may have installed.

Each shim is a tiny Bash script that in turn runs rbenv exec. So with rbenv in your path, irb is equivalent to rbenv exec irb, and ruby -e "puts 42" is equivalent to rbenv exec ruby -e "puts 42".

The rbenv exec command figures out what version of Ruby you want to use, then runs the corresponding command for that version. Here's how:

If the RBENV\_VERSION environment variable is set, its value determines the version of Ruby to use.

If the current working directory has an .rbenv-version file, its contents are used to set the RBENV\_VERSION environment variable.

If there is no .rbenv-version file in the current directory, rbenv searches each parent directory for an .rbenv-version file until it hits the root of your filesystem. If one is found, its contents are used to set the RBENV\_VERSION environment variable.

If RBENV\_VERSION is still not set, rbenv tries to set it using the contents of the \~/.rbenv/version file.

If no version is specified anywhere, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path.

(You can set a project-specific Ruby version with the rbenv local command, which creates a .rbenv-version file in the current directory. Similarly, the rbenv global command modifies the \~/.rbenv/version file.)

Armed with an RBENV\_VERSION environment variable, rbenv adds \~/.rbenv/versions/$RBENV\_VERSION/bin to the front of your PATH, then execs the command and arguments passed to rbenv exec. Voila!

For a thorough look at exactly what happens under the hood, try setting RBENV\_DEBUG=1 and running a Ruby command. Every Bash command that rbenv runs will be written to your terminal.

Now, rbenv is just concerned with switching versions, but a thriving ecosystem of plugins will help you do everything from installing Ruby to setting up your environment, managing "gemsets" and even automating bundle exec.

I am not quite sure what IRC support has to do with switching Ruby versions, and rbenv is designed to be simple and understandable enough not to require support. But should you ever need help, the issue tracker and Twitter are just a couple of clicks away.

Disclosure: I am the author of rbenv, ruby-build, and rbenv-vars.

```
$ rvm list
$ rvm gemset list
```

```
$ gem install bundler
$ gem install nokogiri
$ gem install rails --version=4.2.0

$ rails -v

$ bundle install
```

<https://github.com/ComPlat/chemotion_ELN/blob/master/INSTALL.md>

```
# openbabel - 1

# Gemfile
gem 'openbabel', '2.3.2.1', git: 'https://github.com/cubuslab/openbabel-gem'

# install base on
https://github.com/cubuslab/openbabel/blob/master/INSTALL
```

```
# install rmagick

$ brew unlink imagemagick
$ brew install imagemagick@6 && brew link imagemagick@6 --force
```

```
# nvm
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.4/install.sh | bash
$ nvm install
$ nvm i
```

```
# you should able to run rails sever

$ bundle install
$ rake db:create
$ rake db:migrate
$ rails s
```

```
# openbabel - 2

# restore Gemfile to
gem 'openbabel', '2.4.0.1', git: 'https://github.com/ComPlat/openbabel-gem', branch: 'openbabel-2-4-x'

$ cp /Users/jason/.rvm/gems/ruby-2.3.1@chemotion/bundler/gems/openbabel-gem-1a9ecb42781a/lib/openbabel/openbabel.bundle /Users/jason/.rvm/gems/ruby-2.3.1@chemotion/bundler/gems/openbabel-gem-837eec9e660b/openbabel/lib

$ bundle instll

$ rails s
```

### Adding a Gemset to an Existing Application

```
$ rvm use ruby-2.4.1@myapp --ruby-version --create

$ gem install rails
$ bundle install
```

#### Specifying a Gemset for an Existing Application

```
$ echo "ruby-2.2.0" > .ruby-version
$ echo "myapp" > .ruby-gemset
```

## ENV

```
$ vim .zshrc

// in .zshrc
export PASSWORD=password

// save & close
```

```
// open new console
$ irb
$ ENV[“PASSWORD”]
password
```

In this way, you don't have to set them inside your rails application code.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huang-jason.gitbook.io/ruby-rails-syntax/rvm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
