I’m a complete beginner in Ruby on Rails, so excuse me if this is a
ridiculous question. Just to bare in mind, I’m using Mac OSX (Snow
Leopard), Rails 3, and sqlite3 as a database. I’ve checked, and
everything is up to date (Rails, Ruby, Gems). I am simply creating a
test application, and I understand the way to run that is by running the
‘rails server’ command in Terminal. Unfortunately, that results in an
error message (in red) saying ‘Could not find gem ‘sqlite3 (>= 0,
runtime)’ in any of the gem sources listed in your Gemfile.’
Now I’ve checked if sqlite3 is listed in the GemFile, and it is. Here’s
what it says (this is just the first part of the GemFile, I didn’t want
to post the whole thing of course):
Is the default setup correct? If not, what would be an appropriate way
to set it up?
On a sidenote, if anyone knows how to get rid of MySQL (to start fresh)
on a mac, please let me know. I’m not sure where the default
installation is, and I would like to get rid of it.
Now I’ve checked if sqlite3 is listed in the GemFile, and it is. Here’s
what it says (this is just the first part of the GemFile, I didn’t want
to post the whole thing of course):
Have you run
bundle install
If so what does it say about sqlite3 in Gemfile.lock?
Let me qualify the fact that I am still getting up to speed with
bundler, so take this advice with a grain of salt. I don’t know if this
is still necessary, but in my Gemfile I have:
gem ‘sqlite3-ruby’, :require => ‘sqlite3’
So the gem I’m using is sqlite3-ruby but the library is sqlite3.
If just running bundle install doesn’t work, you might try changing the
gemfile as above and then rerunning bundler (bundle install),
I have run bundle install, and that runs fine. The ‘rake db:create’
command also produces the same error.
To peter, if you had seen the attached GemFile, it does say additionally
that part as one of the gems. Apologies for not initially writing it.
But the one
gem ‘sqlite3-ruby’, :require => ‘sqlite3’
is commented out (it starts with #). I think Peter is probably right.
Remove the line
gem ‘sqlite3’
and uncomment the currently commented out one. Then run
bundle install
again.
As a side note question, should Gemfile.lock be added to the repository
and uploaded to the production server?
This would have been better as a new thread since it is nothing to do
with the OPs problem as far as I know.
You should run bundle install on the production server, so I suppose
the answer is no, though I have not used bundler on a production
server yet, so others may correct me.
As a side note question, should Gemfile.lock be added to the repository
and uploaded to the production server?
Generally it’s not a good idea to include generated artifacts in a
repository, but I do check my gemfile.lock in for a number of reasons.
Firstly it’s good documentation as it shows clearly in the commit log
the gems, versions and dependencies (and you can easily see what new
dependencies are introduced with each gem which can be useful).
Also, my understanding is that in production mode, the --deployment flag
should be used, and that required a gemfile.lock to ensure your
production version is using the same versions that you tested in dev and
production.