Your Ruby version is 1.9.3, but your Gemfile specified 2.2.4

I’m trying to create a scraper, but I keep getting Ruby version mismatches. I’ve tried specifying many different versions and ranges of versions in the Gemfile, and while these versions are recognised at the start of the output (e.g. “Using Ruby version: ruby-2.2.4”), the version is not recognised by other parts of the output, which causes the run to fail with an error (“Your Ruby version is 1.9.3, but your Gemfile specified 2.2.4”).

Is there somewhere else I need to specify Ruby version for consistency?

My URL is https://morph.io/appleorange1/victorianparliamentmemberdata

Thanks!

Hey @appleorange1 :slight_smile: do you see that error on your local machine as well as on morph.io?

Hey, @equivalentideas :slight_smile: I thought that it did work locally, but as it turns out, it didn’t (though with a different error). I’m going to try starting again from scratch.

How are you managing Ruby locally @appleorange1? With rbenv or rvm? Also, are you running your scraper with bundle exec on the from of the command? e.g. bundle exec ruby scraper.rb.

I’m not using rbenv or rvm, @equivalentideas. I have just been using bundle (but I have been running the commands in the way you described). What would you recommend, rbenv or rvm?

Hey Riley,

Sorry for the slow response :slight_smile:

Using some kind of ruby version manager is a good idea, because it saves you having to manage it yourself. Some projects you might hack on want you to use one version, and others might want a different one. rvm and rbenv help you set ruby versions and then manage the switching for you pretty seemlessly.

I personally use rbenv and find it good. I used to use rvm and found that more complicated—but also I’ve learned a lot since then so ¯_(ツ)_/¯ rvm seems to be a bit more widely used/standard, and it’s what most OpenAustralia Foundation use in production.

rbenv will get you to set a ruby version in a .ruby-version file, but morph looks in the Gemfile for a ruby version, so you end up setting it in both places which creates a little duplication. But I don’t mind.

Here’s a good guide for setting up rbenv that I used https://robots.thoughtbot.com/using-rbenv-to-manage-rubies-and-gems

Let me know how you go :slight_smile:

No problem; the only reason I sent an email was that we had been doing that before, and I wasn’t sure if you had notifications set up. :slight_smile:

I’ve followed the guide, but when I tried running my scraper, I got the error

Could not find rake-12.0.0 in any of the sources

From looking on the internet, it seems that this problem is indicative of a version mismatch somewhere in the system.

I confirmed that there is indeed a problem with the way I’ve set rbenv up, because if (as suggested in this link) I type

$ rbenv install 2.2.4
$ rbenv global 2.2.4
$ ruby -v

I get the output

ruby 2.3.3p222 (2016-11-21) [arm-linux-gnueabihf]

Which implies that the version isn’t changing.

I installed rbenv using apt-get - perhaps I need to compile it locally?

Arg, sorry I missed this again! We do have notifications set up in Slack, but I missed them as I’ve been at a conference.

When you run your scraper are you using bundle exec, e.g. bundle exec ruby scraper.rb ?

What do you get running rbenv version

Here’s what I get:

> ruby -v                                                                                                                                                                       
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]
> rbenv version                                                                                                                                                                 
2.3.1 (set by /Users/Luke/git/morph/.ruby-version)
> which ruby                                                                                                                                                                    
/Users/Luke/.rbenv/shims/ruby

Notice the which ruby shows it’s using the rbenv one. It sounds like it could be an issue with your $PATH.

rbenv seems to recommend installing it using git rather than a package manager like apt-get, unless you’re on a mac. https://github.com/rbenv/rbenv#installation