1

I'm a ruby/rails newbie.

Here is my gemfile:

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

gem 'rails', '4.0.0'

group :development do
  gem 'sqlite3', '1.3.8'
  gem 'ruby-debug-ide'
end

gem 'sass-rails', '4.0.0'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
gem 'wash_out', :git => 'git://github.com/inossidabile/wash_out.git'
gem 'haml'
gem "railties", "~> 4.0.0"

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

On bundle update, I get this:

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    rails (= 4.0.0) ruby depends on
      railties (= 4.0.0) ruby

    sass-rails (= 4.0.0) ruby depends on
      railties (4.0.1.rc1)

The sass-rails issue should be solved since I'm using ~> correct? How can I have both rails and sass-rails installed at the same time?

ahmet
  • 4,955
  • 11
  • 39
  • 64
Josh Nankin
  • 2,518
  • 4
  • 28
  • 45

3 Answers3

7

If you put sass-rails before rails in your Gemfile, it resolves correctly.

Tim Moore
  • 8,958
  • 2
  • 23
  • 34
  • Indeed it does, why does that work if I can only use one version of a gem at a time, as per jibender's answer below? – Josh Nankin Oct 18 '13 at 14:31
  • I'm not sure what he means by his answer. Your Gemfile looks OK to me, I think this is a resolution bug in Bundler. – Tim Moore Oct 19 '13 at 09:14
  • What he said make sense to me though. I only selected your answer because it was an easier fix (but I don't understand why it works). I can only use one version of railties, correct? And sass-rails requires 4.0.1 or greater whereas rails requires 4.0.0 exactly. So why does this work? – Josh Nankin Oct 21 '13 at 00:51
  • 1
    Actually, I just noticed one difference between sass-rails 4.0.0 and sass-rails 4.0.1: version 4.0.0 depends on `'railties', '>= 4.0.0.beta', '< 5.0'` but 4.0.1 depends on `'railties', '>= 4.0.0', '< 5.0'`. Including 'beta' in the dependency allows pre-release versions, which is why it resolved to 4.0.1.rc1. When you upgrade to sass-rails 4.0.1, it no longer includes a pre-release version in its dependencies, so it will only allow released versions. So Jonathan Bender's answer is a better solution. – Tim Moore Oct 22 '13 at 08:21
3

Your problem is that you can only use one version of a gem at a time. the ~> will only allow for version changes on that gem.

You need to change the version of sass-rails you're requiring to 4.0.1.

Jonathan Bender
  • 1,911
  • 4
  • 22
  • 39
1

You should update the following line in your Gemfile:

gem 'rails', '4.0.0'

to

gem 'rails', '~> 4.0.0'

and then run bundle update.

sequielo
  • 1,541
  • 1
  • 18
  • 27