Trouble Getting the Rails Server Started

后端 未结 6 2005
逝去的感伤
逝去的感伤 2021-01-25 23:43

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.


        
相关标签:
6条回答
  • 2021-01-26 00:11

    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

    0 讨论(0)
  • 2021-01-26 00:12

    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.

    0 讨论(0)
  • 2021-01-26 00:17

    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.

    0 讨论(0)
  • 2021-01-26 00:21

    there were several links about your problem :

    • Install sqlite3 on mac osx?
    • Snow Leopard & Ruby on Rails - SQLite3 issue
    • http://railsforum.com/viewtopic.php?id=23018
    0 讨论(0)
  • 2021-01-26 00:23

    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):

    1. Compile the source (not as bad as it sounds) http://www.sqlite.org/download.html
    2. Install MacPorts (why the port command was not found) http://www.macports.org/install.php
    3. Don't use sqlite. Instead use mysql or another DB of your choice.

    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.

    0 讨论(0)
  • 2021-01-26 00:23

    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.

    0 讨论(0)
提交回复
热议问题