Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 301
Elliot Avatar asked Dec 14 '22 03:12

Elliot


1 Answers

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.

like image 126
deau Avatar answered Dec 15 '22 16:12

deau