Ruby-on-rails 在 mac osx 上安装 sqlite3?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1143776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Install sqlite3 on mac osx?
提问by Elliot
I just bought a new MBP
我刚买了一个新的 MBP
I've read online Sqlite3 already exists on OSX.
我已经在线阅读了 OSX 上已经存在的 Sqlite3。
I've downloaded mac ports (and installed it) as well as the bin file for sqlite3 from the official web site.
我已经从官方网站下载了 mac 端口(并安装了它)以及 sqlite3 的 bin 文件。
In a guide I'm reading about rails, which tells me to update sqlite3, I run the following in terminal: sudo port upgrade sqlite3
在我正在阅读的关于 rails 的指南中,它告诉我要更新 sqlite3,我在终端中运行以下命令:sudo port upgrade sqlite3
I receive the following error: Error: sqlite3 is not installed
我收到以下错误:错误:未安装 sqlite3
I am so lost! Please help
我很失落!请帮忙
采纳答案by Lou Franco
It's not installed via mac ports, so port doesn't know about it. You could either do an install via port or get rails to use the one that's installed on the Mac already.
它不是通过 mac 端口安装的,所以端口不知道它。您可以通过端口进行安装,也可以使用 Rails 来使用 Mac 上已经安装的那个。
回答by deau
I don't remember the default configuration, but like you i installed sqlite myself. You can check your sqlite installation is complete by typing using the whichcommand in the OS X terminal:
我不记得默认配置,但和你一样,我自己安装了 sqlite。您可以通过which在 OS X 终端中输入以下命令来检查您的 sqlite 安装是否完成:
$ which sqlite3
/opt/local/bin/sqlite3
If whichdoesn't reveal anything, then sqlite3 isn't in your system's PATH. Use the catcommand to see how that's set up (in your /etc/profile file;)
如果which没有显示任何内容,则 sqlite3 不在您系统的 PATH 中。使用cat命令查看它是如何设置的(在您的 /etc/profile 文件中;)
$ cat /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/opt/svn/subversion-1.4.3/bin:$PATH"
export PATH="/opt/ruby/bin:$PATH"
export PATH="/opt/sqlite/bin:$PATH"
You can open that file in a text editor and add the path to the lines at the bottom. You can see I've installed sqlite to /opt/sqlite, not /usr/local, so i've had to add that to my path. This tells the system to check there for executable files when a command is given.
您可以在文本编辑器中打开该文件并将路径添加到底部的行中。您可以看到我已将 sqlite 安装到 /opt/sqlite,而不是 /usr/local,因此我必须将其添加到我的路径中。这告诉系统在给出命令时检查那里的可执行文件。
Once that's done you need to ensure that Ruby has the functionality it needs to interact with sqlite. We do that by installing the sqlite3 gem. Maybe you don't need to:
完成后,您需要确保 Ruby 具有与 sqlite 交互所需的功能。我们通过安装 sqlite3 gem 来做到这一点。也许你不需要:
$ sudo gem list Password: *** LOCAL GEMS *** # ...loads of gems listed ... sqlite3-ruby (1.2.4) # ... loads of gems listed ...
If it's not there, `sudo gem install sqlite3-ruby' will sort you out in no time. Rails should work with sqlite out of the box if you take those two steps.
如果它不存在,`sudo gem install sqlite3-ruby' 会立即帮你解决。如果您采取这两个步骤,Rails 应该可以开箱即用地使用 sqlite。
回答by effkay
To install the sqlite gem the binary won't be enough afaik. You'll need the amalgamation tarball from the sqlite website or install it via ports:
要安装 sqlite gem,二进制文件是不够的。您将需要来自 sqlite 网站的合并 tarball 或通过端口安装它:
sudo port install sqlite3
回答by Patrick Sereno
I've seen many posts that recommend you install XCode Tools. I already had XCode 3.2 Installed. Installing XCode from the CD didn't help.
我看过很多推荐你安装 XCode 工具的帖子。我已经安装了 XCode 3.2。从 CD 安装 XCode 没有帮助。
What did help is the following:
有什么帮助如下:
sudo env ARCHFLAGS="-arch x86_64" gem install sqlite3-ruby
I believe the "env ..." statement will also help if you're trying to install mysql on Snow Leopard.
如果您尝试在 Snow Leopard 上安装 mysql,我相信“env ...”语句也会有所帮助。

