1

I'd like to set up each Ruby project/app with the associated Ruby version, rspec version and gems.

For the most part, I'll be using using the current version of Ruby, but for several apps I have to use Ruby -1.9.3 and the appropriate rspec version.

Gemfile

source "https://rubygems.org"

ruby '1.9.3'
gem 'rspec', "1.9.3"
gem 'json'
gem 'spreadsheet' 
gem "pdf-reader", "~> 1.3"

Running;

bundle install 

Results in;

$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Could not find gem 'rspec (= 1.9.3) ruby' in the gems available on this machine

Not sure what to do from here.

1 Answer 1

3

You seem to have specified an invalid version of RSpec. Try one listed here. Actually you might need 1.3.2 or earlier for use with Ruby 1.9.3 if I read the documentation correctly--oh wait..never mind about that! I believe I jumped to an invalid conclusion there having only spot checked the dependencies for you.

EDIT: To address the further question regarding the disconnect between the actual ruby version configured and the expected one. Per bundler documentation here (second to last paragraph on page) the line "ruby '1.9.3'" serves to document your expectation that the gems will be used with that specific version of ruby and bundler raises an exception when that is not the case--as you are reporting in your configuration. The Gemfile alone cannot also configure your ruby environment, but only the ruby gems. Since it is common to use various versions of Ruby, there are a few common solutions that facilitate that. Personally, I like chruby for this, but rbenv and rvm have also been popular alternatives. Hope it helps!

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, @unigeek, that solved the rspec error. I've opted for: 'gem 'rspec', "1.3.2" However running bundle install results in; Your Ruby version is 2.2.0, but your Gemfile specified 1.9.3
Updated my answer to address your concern about the exception Bundler raises with respect to your Ruby version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.