Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

ruby on rails - Install sqlite3 on mac osx?

I just bought a new MBP

I've read online Sqlite3 already exists on OSX.

I've downloaded mac ports (and installed it) as well as the bin file for sqlite3 from the official web site.

In a guide I'm reading about rails, which tells me to update sqlite3, I run the following in terminal: sudo port upgrade sqlite3

I receive the following error: Error: sqlite3 is not installed

I am so lost! Please help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 which command in the OS X terminal:

$ which sqlite3
/opt/local/bin/sqlite3

If which doesn't reveal anything, then sqlite3 isn't in your system's PATH. Use the cat command to see how that's set up (in your /etc/profile file;)

$ 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.

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:

$ 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...