微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – 通过bundler安装sqlite3 gem时出错

我正在尝试在我的帐户(共享主机上的CentOS)上安装sqlite3-ruby gem(版本1.3.4),所以我需要安装这个没有root用户),而安装的sqlite的版本对于更新的版本来说不够新的sqlite3-ruby,所以我需要在我的帐户下编译库.我使用的sqlite的版本是1.7.0,因为我发现有更新的版本的问题.

我已经提前完成了 – 我下载了sqlite-3.7.0.tar.gz并安装如下:

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

然后去我的rails 3应用程序,并运行以下:

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

然后:

bundle install --path vendor/bundle

但是,我收到以下内容,我的软件包无法完全安装:

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,它似乎已经没有了.

这里有一些额外的信息:

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,并运行以下操作:

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

这个错误信息让我

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

任何其他想法?

解决方法

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

.bash_profile设置:

# .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”

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

原文地址:https://www.jb51.cc/ruby/273765.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐