Ошибка при установке sqlite3 gem через bundler
Я пытаюсь получить в моей учетной записи sqlite3-ruby gem (версия 1.3.4) (CentOS на общем хостинге, поэтому мне нужно установить это без 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
Изменить:
Я пошел вперед и изменил с sqlite3-ruby на sqlite3 в своем Gemfile и выполнил следующее:
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
Любые другие идеи?
Ответы
Ответ 1
Здесь решение, которое я проверил, работает.
.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"
bundle config build.sqlite3 --with-sqlite3-include=$HOME/include --with-sqlite3-lib=$HOME/lib --with-sqlite3-dir=$HOME/bin
bundle install --path vendor/bundle
Ответ 2
В Ubuntu:
sudo apt-get install libsqlite3-dev
Затем будет запущена установка пакета.
Ответ 3
Установите пакет "sqlite-devel" для создания собственных расширений "sqlite3" в системах на основе RH.
В Debian-системах установите пакет "libsqlite3-dev" .
Ответ 4
В CentOS вы можете использовать yum (проверенные работы)
yum install sqlite sqlite-devel
gem install sqlite3
Ответ 5
gem sqlite3 требует sqlite 3.6.16+. CentOS имеет v3.3.6
Итак, пользователю CentOS необходимо:
wget "http://www.sqlite.org/sqlite-autoconf-3071000.tar.gz"
тогда распакуйте и:
cd sqlite-autoconf-3071000
./configure --prefix=/usr/local/sqlite-3.7
make
make && install
попробуйте gem install sqlite3
СНОВА.