Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Gemfile and Gemset


  • Please log in to reply
6 replies to this topic

#1 orrymr

orrymr

    Signalman

  • Members
  • 11 posts
  • LocationJohannesburg, South Africa

Posted 30 January 2014 - 12:02 PM

Greetings and/or salutations

 

I'm a little (very very) confused by these things. Does a Gemfile specify what is in a given Gemset? Or does using a particular Gemset before running "$ rails new project_name" specify what'll be in that Gemfile?



#2 ffmegaman

ffmegaman

    Passenger

  • Members
  • 5 posts

Posted 31 January 2014 - 06:12 AM

I'm new to rails as well and would like some clarification on Gemfile and Gemset too. So far I've been under the assumption that Gemfile is specific to an app where as a Gemset is specfic to the ruby installation itself?



#3 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 31 January 2014 - 09:36 AM

ffmegaman has it.

 

Normally you can have a global gemset. This is a box of all the gems you've installed on your computer.

 

Sometimes you'd like to organise this box. You do this, by creating a new one, and fill it with specific gems. These specific gems comes from the Gemfile (or are at least specified in the Gemfile). When running bundle install you look at the Gemfile, then at the Gemfile.lock and then into the box (gemset). If the gem is specified in the Gemfile, you look to Gemfile.lock as to which version the project is locked to. Then you look into the gemset and see if you already have this gem installed in this version, or if you need to download it.

 

When doing a bundle update, you just look at Gemfile and try to figure out which version of all the gems are satisfying all the constrains (dependencies) and then you look into the box to see which gems should be updated.

 

I hope that clarified it a bit?


  • orrymr likes this

Blog: http://ohm.sh | Twitter: madsohm


#4 ffmegaman

ffmegaman

    Passenger

  • Members
  • 5 posts

Posted 31 January 2014 - 11:58 AM

Thanks Ohm! Your explanation was very clear. By the way, if I don't organize my gemset, are there consequences in the long run? (Sorry for hijacking the OP's thread)

#5 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 31 January 2014 - 01:48 PM

Do note that gemsets are a RVM specific thing. If you're not running with RVM, no need to worry about it.

 

No, there are no consequences of not using either gemsets or RVM (I myself use rbenv instead)

More info can be found on RVM's page: http://rvm.io/gemsets/basics


Blog: http://ohm.sh | Twitter: madsohm


#6 ffmegaman

ffmegaman

    Passenger

  • Members
  • 5 posts

Posted 01 February 2014 - 02:58 AM

I do use RVM. Thanks OHM. You are definitely the most helpful person.

#7 orrymr

orrymr

    Signalman

  • Members
  • 11 posts
  • LocationJohannesburg, South Africa

Posted 05 February 2014 - 11:25 AM

Thank you for both of your responses! They've helped demystify a few points.

 

So if I go:

$ rvm use 2.0.0@railstutorial_rails_4_0 --create --default 

(taken from Michael Hartl's book)

 

means that I'm now using rails 2.0.0 and associating the railstutorial_rails_4_0 gemset with it as the default gemset.

 

Now, in my gemfile I've got:

source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0

gem 'rails', '4.0.2'

group :development do
  gem 'sqlite3', '1.3.8'
end

gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

Why is the #ruby-gemset=railstutorial_rails_4_0 line necessary? Doesn't the previous line, ruby '2.0.0', mean that I'm using ruby 2.0.0 which is already associated with that gemset?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users