When I run \'rails server\' I get the following error:
Could not find gem \'sqlite3 (>= 0, runtime)\' in any of the gem sources listed in your Gemfile.
If you have problems talking about /usr/local/bin/ruby extconf.rb checking for sqlite3.h
then it's probably something to do with macports.
First, make sure you have xcode installed. Run:
gcc
and you should get:
i686-apple-darwin10-gcc-4.2.1: no input files
If you do, then let's install homebrew
Then, a list of commands to install homebrew, update rubygems, and upgrade rails
brew install sqlite
gem update --system
gem install bundler
gem install rails -v=3.0.8
Then, to check, rails -v
should output Rails 3.0.7
I'm summing up in a reply. So :
1) Install macports : http://www.macports.org/install.php - It has a dmg installer, will take 2 minutes.
2) Once you have it installed, do a 'bundle install' and sqlite3 will be installed as specified in your Gemfile.
When you use port look for a package called sqlite3-dev or something similar to that. The -dev part is key. I don't use MacPorts, but on my Ubuntu install this is the needed package.
When you want to install a package that you plan to link against, always look for the -dev version. The -dev means that it installs the header files among other things that are needed for development against that package.
Most likely your gem cannot build the sqlite3 native extension because it is looking for the header files, if this does not solve your problem please post the log file for the gem installation.
there were several links about your problem :
If you are running 10.4 or earlier you don't have sqlite 3 (the actual DB engine, not the gem) installed by default. You have 3 options (assuming upgrading your OS to 10.5 or 10.6 is not an option):
I recommend the latter if you are going to deploy using some DB other than sqlite, and deploying with sqlite generally isn't a good idea. I like to keep my development and production environments fairly uniform to help avoid gotchas and such.
I hope this helps.
From your Rails directory:
cd ..
cd rails-root
ruby -v
gem list sqlite3
bundle install
gem list sqlite3
bundle exec rails server
What might be happening is you're bundling in a Rails app that has an .rvmrc file. I've seen cases where you bundle under a version of Ruby that doesn't match the .rvmrc file or some other mismatch so when you bundle sqlite3 it isn't under the same version of Ruby that rails is using when you run the app.
Changing out of the directory and back into it, and running rails server prefixed with bundle exec are my two suggestions.