无法启动 Rails 服务器 [英] Trouble Getting the Rails Server Started

查看:105
本文介绍了无法启动 Rails 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行rails server"时出现以下错误:

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.

我的 GemFile 看起来像这样:gem 'sqlite3'

My GemFile looks like this: gem 'sqlite3'

此外,当我运行 port 命令时,它说它无法识别该命令:

Also when I run the port command it says it does not recognize that command:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ port install sqlite3 +universal
-bash: port: command not found

有什么建议吗?

更新 1:

我运行 sudo gem install sqlite3 并收到以下消息:

I run sudo gem install sqlite3 and got the following message:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ sudo gem install sqlite3
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... no
sqlite3 is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite3-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

更新 2:(GemFile 的内容)

UPDATE 2: (Contents of GemFile)

source 'http://rubygems.org'

gem 'rails', '3.0.7'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'

# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
#   gem 'webrat'
# end

更新 3:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ 端口搜索 sqlite3-bash: 端口: 命令未找到

更新 4:

下载安装 Macports 后,我再次运行捆绑安装,结果如下:

After downloading the install Macports I ran the bundle install again and here is the result:

使用本机扩展安装 sqlite3 (1.3.3)/usr/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:inbuild_extensions': ERROR: Failed to buildgem 原生扩展.(Gem::Installer::ExtensionBuildError)

Installing sqlite3 (1.3.3) with native extensions /usr/local/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:inbuild_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/usr/local/bin/ruby extconf.rb检查 sqlite3.h ... 是的检查 -lsqlite3 中的 sqlite3_libversion_number()... 否缺少 sqlite3.尝试端口安装 sqlite3 + 通用"或yum install sqlite3-devel"并检查您的共享库搜索路径(您的 sqlite3 共享库所在的位置).* extconf.rb 失败 *由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件.检查 mkmf.log 文件以获取更多信息细节.您可能需要配置选项.

/usr/local/bin/ruby extconf.rb checking for sqlite3.h... yes checking for sqlite3_libversion_number() in -lsqlite3... no sqlite3 is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel' and check your shared library search path (the location where your sqlite3 shared library is located). * extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

`

更新 5:

哪个 sqlite3 给了我以下内容:

which sqlite3 gives me the following:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ which sqlite3
/opt/local/bin/sqlite3

更新 5:

which -a sqlite3 给了我以下内容:

which -a sqlite3 gives me the following:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ which -a sqlite3
/opt/local/bin/sqlite3
/usr/local/bin/sqlite3
/usr/bin/sqlite3

推荐答案

如果您在讨论 /usr/local/bin/ruby extconf.rb 检查 sqlite3.h 时遇到问题与 macports 相关.

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.

首先,确保你已经安装了 xcode.运行:

First, make sure you have xcode installed. Run:

gcc

你应该得到:

i686-apple-darwin10-gcc-4.2.1: no input files

如果你这样做了,那么让我们安装自制软件

If you do, then let's install homebrew

然后是安装 homebrew、更新 ruby​​gems 和升级 rails 的命令列表

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

然后,要检查,rails -v 应该输出 Rails 3.0.7

Then, to check, rails -v should output Rails 3.0.7

这篇关于无法启动 Rails 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆