Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a version manager for Ruby gems?

I'm a new Rails developer. I recently took a class on Rails and now I'm trying to make sure I'm growing in my skill by self-assigning projects that push me. One thing I'm trying to do now is use Radiant CMS to build a blog site. However, I'm running into some problems downloading the Radiant gem. Here's what I did:

  1. When I first tried gem install radiant, it installed most of the required gems but then threw a warning (which I unfortunately did not save verbatim), which was along the lines of:

    railties executable will overwrite rails executable. Overwrite? Y/n
    
  2. Stupidly, I chose "Y". As soon as I did I tested my rails gem by writing rails new testproject and it failed. So I then re-ran gem install rails, told it to overwrite the "railties" executable, then ran gem uninstall radiant to get rid of the core radiant gem (although I do still have railties).

  3. Now, my Rails gem is fixed, and I can create new Rails projects without an issue. However, I reinstalled the Radiant gem, and while it installed, it fails to create a project every time I run it.

I'm pretty sure I broke something, but I'm not terribly concerned about that. What I am concerned about is the fact that it seems that the Radiant gem doesn't really coexist well with the Rails gem, which leads me to my question:

Is there any way to create separate, self-contained ruby gem environments where the current Ruby version will only use the gems in the specified environment?

In essence, I'm looking for what rbenv does, but for collections of gems rather than Ruby versions.

Currently, I have Homebrew installed and I am using rbenv as my version manager. Everything I can find so far talks about managing gems on a project-by-project basis; I'm looking for something that will manage and keep separate the gems that create the projects in the first place. So, for example, environment_a contains rails and httparty while environment_b contains radiant and railties.

I'm not above completely obliterating rbenv and all of my gems and starting from scratch, either, so that's a possibility (and an advantage of being a noob).

like image 526
JohnTheSixth Avatar asked Jan 10 '23 12:01

JohnTheSixth


2 Answers

You should check bundler, as it does exactly what you need.

like image 123
Thomas Avatar answered Jan 18 '23 20:01

Thomas


Yes: rbenv-gemset

I think that it is better than RVM because it is less invasive.

I have been using rbenv and rbenv-gemset for about 2 years and find it easy to use. It makes it easy to encapsulate the Ruby and gemset in a project, run multiple Rubies and gemsets on one machine, and move a project to another machine.

You can use ruby-build to install other versions of Ruby. There is a trick to installing the latest versions of Ruby.

You may want to have a look at How do I ensure ruby gems are installed in right place to be executed by bundler? It has some relevant (and hopefully useful) info.

like image 21
B Seven Avatar answered Jan 18 '23 22:01

B Seven