Skip to content

Commit 2b83324

Browse files
author
Ignacio Galindo
committed
* Post "using rbenv to manage your rubies"
1 parent 171aef7 commit 2b83324

File tree

63 files changed

+2354
-1539
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2354
-1539
lines changed

Gemfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ source :gemcutter
33
gem 'jekyll'
44
gem 'rdiscount'
55
gem 'RedCloth'
6-
gem 'pygmentize'
6+
gem 'pygmentize'
7+
gem 'gsl'

Gemfile.lock

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ GEM
66
fast-stemmer (>= 1.0.0)
77
directory_watcher (1.4.0)
88
fast-stemmer (1.0.0)
9+
gsl (1.14.7)
10+
narray (>= 0.5.9)
911
jekyll (0.10.0)
1012
classifier (>= 1.3.1)
1113
directory_watcher (>= 1.1.1)
@@ -14,6 +16,7 @@ GEM
1416
liquid (2.2.2)
1517
maruku (0.6.0)
1618
syntax (>= 1.0.0)
19+
narray (0.6.0.1)
1720
pygmentize (0.0.3)
1821
rdiscount (1.6.8)
1922
syntax (1.0.0)
@@ -23,6 +26,7 @@ PLATFORMS
2326

2427
DEPENDENCIES
2528
RedCloth
29+
gsl
2630
jekyll
2731
pygmentize
2832
rdiscount
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
layout: post
3+
title: Using rbenv to manage your rubies
4+
author: Ignacio Galindo
5+
6+
avatar: 6be5df410f2695b1341f0c359bc9b461
7+
---
8+
9+
While working with ruby, you have some alternatives to manage your binaries,
10+
but as you think of them, I hope you are not really considering delegating this
11+
task directly to your OS package manager since it is discouraged, otherwise you
12+
would end up with a messy workstation.
13+
14+
There are a few tools that allow you to manage your rubies and gems, the most
15+
popular among them is without doubts [RVM](http://beginrescueend.com/)
16+
(Ruby Version Manager) which in all fairness is good, it provides a CLI to
17+
switch between your rubies and gemsets. If you haven't used RVM, you should
18+
read [this](http://blog.crowdint.com/2010/07/28/getting-started-with-rvm.html).
19+
20+
Even when RVM is great there are a couple things that I don't like about it:
21+
22+
* Personally, I had a painful situation as Linux user, every time I wanted to
23+
get a fresh ruby version with support for readline and zlib libraries and its
24+
dependencies.
25+
26+
* Its gemset management feature tends duplicate gems across your projects. I
27+
get it, sometimes you need to isolate your gems to keep them compatible. But
28+
there is another player in the field, called bundler. (mention down below)
29+
30+
* Plus that last bullet, some colleages have mentioned having a 5~6 GB .rvm
31+
folder.
32+
33+
A couple days ago, I was struggling tracking down a gem that I wasn't sure
34+
where exactly came from, anyway I was about to create a new gemset for a fresh
35+
started when someone adviced me to check out rbenv.
36+
37+
## The rbenv way
38+
39+
A highlight in favor of rbenv is that you don't actually need to worry about
40+
maintaing your gemsets, since it relays on [bundler](http://gembundler.com/)
41+
who takes care of all your application dependencies. Letting you care about
42+
just the version of the ruby you want to use globally, locally and in a per
43+
project basis. Let's check out [rbenv](http://gituhub.com/ssthepenson/rbenv).
44+
45+
*RVM and rbenv aren't friends :(*
46+
47+
First of all, you better avoid using both in the same environment because they
48+
are incompatible. Don't say I didn't warn you.
49+
50+
## Installation
51+
52+
### 1. Get rid of RVM by running:
53+
54+
{% highlight bash %}
55+
$ rvm implode
56+
{% endhighlight %}
57+
58+
### 2. To install rbenv, must be at ~ and clone it:
59+
60+
{% highlight bash %}
61+
$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
62+
{% endhighlight %}
63+
64+
### 3. Add scope for rbenv binaries to your $PATH
65+
66+
{% highlight bash %}
67+
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> .bash_profile
68+
# be sure of do this to your bash source file (e.g. .bashrc, .profile)
69+
{% endhighlight bash %}
70+
71+
### 4. Setup bash autocompletion:
72+
73+
{% highlight bash %}
74+
$ echo 'eval "$(rbenv init -)"' >> .bash_profile
75+
{% endhighlight bash %}
76+
77+
### 5. Restart your shell.
78+
79+
{% highlight bash %}
80+
$ exec
81+
{% endhighlight bash %}
82+
83+
There are two ways of installing rubies with rbenv. From source and *make it*
84+
into "~/.rbenv/versions/<x.x.x-pxxx>" or the one I prefer using *ruby-build*
85+
86+
### 6. Install ruby-build
87+
{% highlight bash %}
88+
$ git clone git://github.com/sstephenson/ruby-build.git ~/.ruby-build
89+
$ cd ~/.ruby-build
90+
$ ./install.sh
91+
# you may need to run with sudo, since it installs a binary in /usr/local/bin
92+
{% endhighlight bash %}
93+
94+
### 7. Install a ruby
95+
96+
Now, we are ready to install a ruby.
97+
98+
*Note:* After a couple times trying to get a ruby with readline support
99+
for my *irb*, I googled and found a way.
100+
101+
*For Ubuntu* I used my readline path:
102+
103+
{% highlight bash %}
104+
$ CONFIGURE_OPTS="--with-readline-dir=/usr/include/readline" rbenv
105+
install 1.9.3-preview1
106+
{% endhighlight bash %}
107+
108+
And there we go, we give it some time, get a coffee or play a ping pong
109+
match. Once it rbenv finishes, and every time after installing a ruby
110+
you need to run:
111+
112+
{% highlight bash %}
113+
$ rbenv rehash
114+
{% endhighlight bash %}
115+
116+
I have to mention, that it seems tricky, but you can set an alias in
117+
your `~/.bash_profile` or export an environment variable.
118+
119+
## Usage
120+
121+
Let's suposse you've got some more rubies, now, how do we specify the
122+
version of ruby we want to use:
123+
124+
*To setup a global ruby you do something like:*
125+
126+
{% highlight bash %}
127+
$ rbenv global 1.9.3-preview1
128+
{% endhighlight bash %}
129+
130+
*To setup a local (per-project) ruby you do:*
131+
132+
{% highlight bash %}
133+
$ rbenv local 1.9.2-p290
134+
# this creates a rbenv-version file in the current folder
135+
{% endhighlight bash %}
136+
137+
*What version of ruby am I using?*
138+
{% highlight bash %}
139+
$ rbenv version
140+
{% endhighlight bash %}
141+
142+
143+
*What versions of ruby do I have?*
144+
{% highlight bash %}
145+
$ rbenv versions
146+
{% endhighlight bash %}
147+
148+
149+
## Conclusions
150+
151+
There are a couple things that remain unexplored, but for now this is a getting
152+
started. In case you miss the gemset, [this](http://github.com/jamis/rbenv-gemset)
153+
is something you might want to look at.
154+
155+
So, give it a try, you might like it. For now I'm happy with my fresh
156+
rbenv install. Let us know your rbenv experience.

_site/2010/07/11/git-initial-configuration.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ <h2>Add color to your life</h2>
158158
<h1>Related Posts</h1>
159159
<ul class="archives">
160160

161-
<li><span><b>11 Jul 2010</b></span> &raquo; <a href="/2010/07/11/git-initial-configuration.html">First Things First... Our initial git configuration</a></li>
162-
163161
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
164162

165163
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
@@ -168,6 +166,8 @@ <h1>Related Posts</h1>
168166

169167
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
170168

169+
<li><span><b>05 Nov 2010</b></span> &raquo; <a href="/2010/11/05/controller-responders-in-rails-3.html">Controller responders in Rails 3</a></li>
170+
171171
</ul>
172172
<div id="disqus_thread"></div>
173173
<script type="text/javascript">

_site/2010/07/18/setting-up-automation-with-cucumber-rspec-autotest.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ <h2>Installing ZenTest, Autotest-Rails y Autotest-Growl</h2>
231231
<h1>Related Posts</h1>
232232
<ul class="archives">
233233

234-
<li><span><b>18 Jul 2010</b></span> &raquo; <a href="/2010/07/18/setting-up-automation-with-cucumber-rspec-autotest.html">Setting up Automation with Cucumber, RSpec, Autotest in RoR 2.3.8</a></li>
235-
236234
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
237235

238236
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
@@ -241,6 +239,8 @@ <h1>Related Posts</h1>
241239

242240
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
243241

242+
<li><span><b>14 Mar 2011</b></span> &raquo; <a href="/2011/03/14/Sinatra-the-green-way.html">Sinatra, the green way</a></li>
243+
244244
</ul>
245245
<div id="disqus_thread"></div>
246246
<script type="text/javascript">

_site/2010/07/28/getting-started-with-rvm.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ <h2>Enjoy!</h2>
233233
<h1>Related Posts</h1>
234234
<ul class="archives">
235235

236-
<li><span><b>28 Jul 2010</b></span> &raquo; <a href="/2010/07/28/getting-started-with-rvm.html">Getting started with Ruby Version Manager (RVM)</a></li>
236+
<li><span><b>30 Sep 2011</b></span> &raquo; <a href="/2011/09/30/using-rbenv-for-managing-your-rubies.html">Using rbenv to manage your rubies</a></li>
237237

238238
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
239239

_site/2010/08/02/instant-blog-using-jekyll-and-heroku.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ <h2>Deploying to Heroku</h2>
244244
<h1>Related Posts</h1>
245245
<ul class="archives">
246246

247-
<li><span><b>02 Aug 2010</b></span> &raquo; <a href="/2010/08/02/instant-blog-using-jekyll-and-heroku.html">Instant blog using Jekyll and Heroku</a></li>
248-
249247
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
250248

251249
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
@@ -254,6 +252,8 @@ <h1>Related Posts</h1>
254252

255253
<li><span><b>14 Mar 2011</b></span> &raquo; <a href="/2011/03/14/Sinatra-the-green-way.html">Sinatra, the green way</a></li>
256254

255+
<li><span><b>28 Jul 2010</b></span> &raquo; <a href="/2010/07/28/getting-started-with-rvm.html">Getting started with Ruby Version Manager (RVM)</a></li>
256+
257257
</ul>
258258
<div id="disqus_thread"></div>
259259
<script type="text/javascript">

_site/2010/08/06/our-git-workflow.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ <h1>Our git workflow</h1>
186186
<h1>Related Posts</h1>
187187
<ul class="archives">
188188

189-
<li><span><b>06 Aug 2010</b></span> &raquo; <a href="/2010/08/06/our-git-workflow.html">Our git workflow</a></li>
190-
191189
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
192190

193191
<li><span><b>07 Dec 2010</b></span> &raquo; <a href="/2010/12/07/improving-your-dev-life-with-ree.html">Improving your development life with Ruby Enterprise Edition</a></li>
@@ -196,6 +194,8 @@ <h1>Related Posts</h1>
196194

197195
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
198196

197+
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
198+
199199
</ul>
200200
<div id="disqus_thread"></div>
201201
<script type="text/javascript">

_site/2010/08/13/fix-incompatibility-with-attachment-fu-and-acts-as-list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,6 @@ <h3>Conclusion</h3>
159159
<h1>Related Posts</h1>
160160
<ul class="archives">
161161

162-
<li><span><b>13 Aug 2010</b></span> &raquo; <a href="/2010/08/13/fix-incompatibility-with-attachment-fu-and-acts-as-list.html">Improve performance between attachment_fu and acts_as_list</a></li>
163-
164162
<li><span><b>14 Jan 2011</b></span> &raquo; <a href="/2011/01/14/building-a-basic-dsl-to-create-callbacks-in-ruby.html">Building a basic DSL to create callbacks in Ruby</a></li>
165163

166164
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
@@ -169,6 +167,8 @@ <h1>Related Posts</h1>
169167

170168
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
171169

170+
<li><span><b>05 Nov 2010</b></span> &raquo; <a href="/2010/11/05/controller-responders-in-rails-3.html">Controller responders in Rails 3</a></li>
171+
172172
</ul>
173173
<div id="disqus_thread"></div>
174174
<script type="text/javascript">

_site/2010/08/17/use-a-project-specific-ruby-version-rvm.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ <h2>Final thoughts</h2>
130130
<h1>Related Posts</h1>
131131
<ul class="archives">
132132

133-
<li><span><b>17 Aug 2010</b></span> &raquo; <a href="/2010/08/17/use-a-project-specific-ruby-version-rvm.html">Use a project specific Ruby version with RVM</a></li>
134-
135133
<li><span><b>28 Jul 2010</b></span> &raquo; <a href="/2010/07/28/getting-started-with-rvm.html">Getting started with Ruby Version Manager (RVM)</a></li>
136134

135+
<li><span><b>30 Sep 2011</b></span> &raquo; <a href="/2011/09/30/using-rbenv-for-managing-your-rubies.html">Using rbenv to manage your rubies</a></li>
136+
137137
<li><span><b>27 Oct 2010</b></span> &raquo; <a href="/2010/10/27/working-with-postgresql-and-rails3.html">Working with PostgreSQL and Rails3</a></li>
138138

139139
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>

_site/2010/08/20/what-i-would-ve-loved-to-know-when-i-first-met-ruby.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,6 @@ <h4>Call all instance methods of a certain class whenever you call a method whos
349349
<h1>Related Posts</h1>
350350
<ul class="archives">
351351

352-
<li><span><b>20 Aug 2010</b></span> &raquo; <a href="/2010/08/20/what-i-would-ve-loved-to-know-when-i-first-met-ruby.html">What I would've loved I had known when I first met Ruby</a></li>
353-
354352
<li><span><b>14 Jan 2011</b></span> &raquo; <a href="/2011/01/14/building-a-basic-dsl-to-create-callbacks-in-ruby.html">Building a basic DSL to create callbacks in Ruby</a></li>
355353

356354
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
@@ -359,6 +357,8 @@ <h1>Related Posts</h1>
359357

360358
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
361359

360+
<li><span><b>25 Feb 2011</b></span> &raquo; <a href="/2011/02/25/why-ruby.html">Why ruby?</a></li>
361+
362362
</ul>
363363
<div id="disqus_thread"></div>
364364
<script type="text/javascript">

_site/2010/08/26/thin-vs-unicorn.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,6 @@ <h2>Machine used:</h2>
526526
<h1>Related Posts</h1>
527527
<ul class="archives">
528528

529-
<li><span><b>26 Aug 2010</b></span> &raquo; <a href="/2010/08/26/thin-vs-unicorn.html">Benchmarking thin vs unicorn</a></li>
530-
531529
<li><span><b>07 Dec 2010</b></span> &raquo; <a href="/2010/12/07/improving-your-dev-life-with-ree.html">Improving your development life with Ruby Enterprise Edition</a></li>
532530

533531
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
@@ -536,6 +534,8 @@ <h1>Related Posts</h1>
536534

537535
<li><span><b>14 Mar 2011</b></span> &raquo; <a href="/2011/03/14/Sinatra-the-green-way.html">Sinatra, the green way</a></li>
538536

537+
<li><span><b>18 Jul 2010</b></span> &raquo; <a href="/2010/07/18/setting-up-automation-with-cucumber-rspec-autotest.html">Setting up Automation with Cucumber, RSpec, Autotest in RoR 2.3.8</a></li>
538+
539539
</ul>
540540
<div id="disqus_thread"></div>
541541
<script type="text/javascript">

_site/2010/08/31/open-and-watch-specific-git-branches-using-gitx.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ <h1>Related Posts</h1>
145145

146146
<li><span><b>06 Aug 2010</b></span> &raquo; <a href="/2010/08/06/our-git-workflow.html">Our git workflow</a></li>
147147

148-
<li><span><b>31 Aug 2010</b></span> &raquo; <a href="/2010/08/31/open-and-watch-specific-git-branches-using-gitx.html">Open and watch specific git branches using gitx</a></li>
148+
<li><span><b>30 Sep 2011</b></span> &raquo; <a href="/2011/09/30/using-rbenv-for-managing-your-rubies.html">Using rbenv to manage your rubies</a></li>
149149

150150
<li><span><b>10 Sep 2010</b></span> &raquo; <a href="/2010/09/10/customize-your-generators-workflow.html">Customize your Generators Workflow in Rails 3.0.0</a></li>
151151

_site/2010/09/06/a-simple-way-to-setup-a-class-for-global-values.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ <h2>Enjoy!</h2>
164164
<h1>Related Posts</h1>
165165
<ul class="archives">
166166

167-
<li><span><b>06 Sep 2010</b></span> &raquo; <a href="/2010/09/06/a-simple-way-to-setup-a-class-for-global-values.html">A simple way to setup a class for global values</a></li>
168-
169167
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
170168

171169
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
@@ -174,6 +172,8 @@ <h1>Related Posts</h1>
174172

175173
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
176174

175+
<li><span><b>28 Jul 2010</b></span> &raquo; <a href="/2010/07/28/getting-started-with-rvm.html">Getting started with Ruby Version Manager (RVM)</a></li>
176+
177177
</ul>
178178
<div id="disqus_thread"></div>
179179
<script type="text/javascript">

_site/2010/09/10/customize-your-generators-workflow.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ <h2>Generators</h2>
255255
<h1>Related Posts</h1>
256256
<ul class="archives">
257257

258-
<li><span><b>10 Sep 2010</b></span> &raquo; <a href="/2010/09/10/customize-your-generators-workflow.html">Customize your Generators Workflow in Rails 3.0.0</a></li>
259-
260258
<li><span><b>30 Nov 2010</b></span> &raquo; <a href="/2010/11/30/rspec-for-really-newbies.html">RSpec for really newbies</a></li>
261259

262260
<li><span><b>24 Jan 2011</b></span> &raquo; <a href="/2011/01/24/how-to-start-writing-a-gem.html">How to start writing a ruby gem</a></li>
@@ -265,6 +263,8 @@ <h1>Related Posts</h1>
265263

266264
<li><span><b>14 Jan 2011</b></span> &raquo; <a href="/2011/01/14/building-a-basic-dsl-to-create-callbacks-in-ruby.html">Building a basic DSL to create callbacks in Ruby</a></li>
267265

266+
<li><span><b>17 Nov 2010</b></span> &raquo; <a href="/2010/11/17/rack-basics-a-rack-introduction.html">Rack Basics - A Rack Introduction</a></li>
267+
268268
</ul>
269269
<div id="disqus_thread"></div>
270270
<script type="text/javascript">

0 commit comments

Comments
 (0)