通过捆绑程序安装 sqlite3 gem 时出错 [英] Error installing sqlite3 gem via bundler

查看:49
本文介绍了通过捆绑程序安装 sqlite3 gem 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的帐户上安装 sqlite3-ruby gem(版本 1.3.4)(共享主机上的 CentOS,所以我需要在没有 root 的情况下安装它)并且安装的 sqlite 版本不够新更新版本的 sqlite3-ruby,所以我需要在我的帐户下编译库.我使用的 sqlite 版本是 1.7.0,因为我发现较新的版本存在问题.

I'm trying to get the sqlite3-ruby gem (version 1.3.4) installed on my account (CentOS on shared hosting, so I need to install this without root) and the version of sqlite installed is not new enough for more recent versions of sqlite3-ruby, so I need to compile the libraries under my account. The version of sqlite I'm using is 1.7.0 as I found there were issues with the more recent versions.

我已经这样做了 - 我下载了 sqlite-3.7.0.tar.gz 并按如下方式安装:

I've gone ahead and done this already - I downloaded sqlite-3.7.0.tar.gz and installed it as follows:

./configure –prefix=$HOME
make && make install

然后转到我的 rails 3 应用程序并运行以下内容:

Then went to my rails 3 application and ran the following:

bundle config build.sqlite3-ruby "--with-sqlite3-include=$HOME/include --with-sqlite3-lib=$HOME/lib"

那么:

bundle install --path vendor/bundle

但是,我得到以下信息并且我的包无法完全安装:

However, I get the following and my bundle fails to fully install:

Installing sqlite3 (1.3.4) with native extensions /usr/lib/ruby/site_ruby/1.8/rubygems/installer.rb:533:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /usr/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... no
checking for sqlite3_initialize()... no
checking for sqlite3_backup_init()... no
checking for sqlite3_column_database_name()... no
checking for sqlite3_enable_load_extension()... no
checking for sqlite3_load_extension()... no
creating Makefile

make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.  -fPIC -g -O2  -fPIC   -c sqlite3.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.  -fPIC -g -O2  -fPIC   -c exception.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.  -fPIC -g -O2  -fPIC   -c backup.c
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I.  -fPIC -g -O2  -fPIC   -c database.c
database.c: In function 'initialize':
database.c:47: error: 'SQLITE_OPEN_READWRITE' undeclared (first use in this function)
database.c:47: error: (Each undeclared identifier is reported only once
database.c:47: error: for each function it appears in.)
database.c:47: error: 'SQLITE_OPEN_CREATE' undeclared (first use in this function)
database.c:72: error: 'SQLITE_OPEN_READONLY' undeclared (first use in this function)
database.c: In function 'set_sqlite3_func_result':
database.c:278: error: 'sqlite3_int64' undeclared (first use in this function)
make: *** [database.o] Error 1

有什么想法吗?这曾经有效,但对于更新版本的 sqlite3-ruby 似乎不再适用.

Any ideas? This used to work, but with more recent versions of sqlite3-ruby it seems like it's a no go anymore.

这里有一些额外的信息:

Here's some additional info:

rails -v
Rails 3.0.9

gem -v
1.7.2

.bash_profile:

PATH=$HOME/bin:$PATH
GEM_HOME=$HOME/gems
GEM_PATH=$HOME/gems
export LD_LIBRARY_PATH=$HOME/lib
export USERNAME BASH_ENV PATH GEM_HOME GEM_PATH

which sqlite3
/home/striketh/bin/sqlite3

我继续将 Gemfile 中的 sqlite3-ruby 更改为 sqlite3 并运行以下命令:

I went ahead and changed from sqlite3-ruby to sqlite3 in my Gemfile and ran the following:

bundle config build.sqlite3 "--with-sqlite3-include=$HOME/include --with-sqlite3-lib=$HOME/lib --with-sqlite3-dir=$HOME"

这条错误信息让我知道:

This error message got me:

make
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_SQLITE3_INITIALIZE -DHAVE_SQLITE3_BACKUP_INIT -I/home/striketh"/include    -fPIC -g -O2  -fPIC   -c sqlite3.c
In file included from ./sqlite3_ruby.h:42,
                 from sqlite3.c:1:
./backup.h:7: error: expected specifier-qualifier-list before 'sqlite3_backup'
make: *** [sqlite3.o] Error 1

还有其他想法吗?

推荐答案

这是我已经验证有效的解决方案.

Here's the solution, which I've verified works.

.bash_profile 设置:

.bash_profile setup:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$HOME/bin:$PATH
GEM_HOME=$HOME/gems
GEM_PATH=$HOME/gems
export LD_LIBRARY_PATH=$HOME/lib
export USERNAME BASH_ENV PATH GEM_HOME GEM_PATH

然后运行:

wget http://www.sqlite.org/sqlite-autoconf-3070701.tar.gz
tar -zxvf sqlite-autoconf-3070701.tar.gz
cd sqlite-autoconf-3070701
./configure --prefix=$HOME
make && make install

cd $RAILS_APP_DIR
vi Gemfile

确保 Gemfile 中有与此类似的行: gem 'sqlite3', "1.3.4"

Make sure a line similar to this is in the Gemfile: gem 'sqlite3', "1.3.4"

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

这篇关于通过捆绑程序安装 sqlite3 gem 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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