Skip to content

Commit 758dc65

Browse files
committed
adding .rvmrc file to automatically set ruby version and gemset name in rvm environments
1 parent 1769c6d commit 758dc65

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.rvmrc

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
3+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
4+
# development environment upon cd'ing into the directory
5+
6+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7+
environment_id="ruby-1.9.3-p125@noid"
8+
rubygems_version="1.8.23"
9+
10+
# Install rubies when used instead of only displaying a warning and exiting
11+
rvm_install_on_use_flag=1
12+
13+
#
14+
# Uncomment following line if you want options to be set only for given project.
15+
#
16+
# PROJECT_JRUBY_OPTS=( --1.9 )
17+
18+
#
19+
# First we attempt to load the desired environment directly from the environment
20+
# file. This is very fast and efficient compared to running through the entire
21+
# CLI and selector. If you want feedback on which environment was used then
22+
# insert the word 'use' after --create as this triggers verbose mode.
23+
#
24+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
25+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
26+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
27+
28+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]; then
29+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
30+
fi
31+
else
32+
# If the environment file has not yet been created, use the RVM CLI to select.
33+
if ! rvm --create "$environment_id"; then
34+
echo "Failed to create RVM environment '${environment_id}'."
35+
exit 1
36+
fi
37+
fi
38+
39+
#
40+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
41+
# it be automatically loaded. Uncomment the following and adjust the filename if
42+
# necessary.
43+
#
44+
# filename=".gems"
45+
# if [[ -s "$filename" ]] ; then
46+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
47+
# fi
48+
49+
# Use the specified rubygems_version
50+
if [[ -n "${rubygems_version}" && ("$(gem --version)" != ${rubygems_version}) ]] ; then
51+
rvm rubygems "${rubygems_version}"
52+
fi
53+
54+
# Ensure that Bundler is installed, install it if it is not.
55+
if ! (command -v bundle > /dev/null) ; then
56+
printf "The rubygem 'bundler' is not installed, installing it now.\n"
57+
gem install bundler
58+
fi
59+

0 commit comments

Comments
 (0)