开发者

Rails 3.1 app can't install sqlite3 gem because libraries are out of date

The latest SQLite3 library available on CentOS 5.6 and which is installed is version 3.3.6. It's my understanding that the sqlite3 ge开发者_JAVA技巧m needs version 3.6 or higher.

How do I get my app to work with SQLite3 without upgrading the library on my server? It's in a work environment and I'm simply not allowed to upgrade it.


You could compile a static library of the version of sqlite you require. Then install the sqlite3 gem with a reference to your new static library.

While I haven't tested this procedure, I could see the process being...

1. Download and extract the SQLite source in a new directory.

mkdir $HOME/sqlite3.7.7.1
cd $HOME/sqlite3.7.7.1
wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz
tar -zxvf sqlite-autoconf-3070701.tar.gz
cd sqlite-autoconf-3070701

2. Configure, compile, and install.

./configure --disable-shared --enable-static --prefix=$HOME/sqlite3.7.7.1
make && make install

3.A. (option1) Install the SQLite gem with a reference to your new static lib.

gem install sqlite3 --with-sqlite3-dir=$HOME/sqlite3.7.7.1

3.B. (option2) Install via bundler. *Assuming sqlite3 has already been added to the Gemfile (thanks to Lester)

bundle config build.sqlite3 \
  --with-sqlite3-include=$HOME/sqlite3.7.7.1/include \
  --with-sqlite3-lib=$HOME/sqlite3.7.7.1/lib \
  --with-sqlite3-dir=$HOME/sqlite3.7.7.1/bin
bundle install


The steps worked for me with one minor tweak. With gem 1.3.7 and rails 3.1.0 for step 3.A. I had to do:

gem install sqlite3 -- --with-sqlite3-dir=$HOME/sqlite3.7.7.1 --with-sqlite3-lib=$HOME/sqlite3.7.7.1/lib

the extra "--" in the middle allowed option to not be parsed by the gem file


This worked for me on a MacBook which had some different versions of sqlite3 that had accumulated over the years.

For me, the gem install was:

gem install sqlite3 -- --with-sqlite3-dir=/path/to/sqlite3/directory

In other words, I did only have to list the main sqlite3 development directory, but I did have to use the extra "--".

This allowed the installation of Rails 3.1 under Max OS X Lion

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜