1

Using Mac OS X 10.5.8 (Leopard) ruby 1.9.3p0 gem version 1.8.14 sqlite3 Version 3.7.9

I also have installed Xcode 3.1.4 (not sure if this is used for installation of gems).

I fetched the sqlite3 gem

gem fetch sqlite3

Then unpacked it

gem unpack sqlite3-1.3.5.gem

And cd'ed into the new directory

cd sqlite3-1.3.5

Executed

ruby setup.rb config

Then cd'ed to ext/sqlite3

and then executed make

This is returning the following error messages:

usernamemac:sqlite3 username$ make
compiling backup.c
compiling 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:79: error: 'SQLITE_OPEN_READONLY' undeclared (first use in this function)
database.c:81: warning: implicit declaration of function 'sqlite3_open_v2'
database.c: In function 'set_sqlite3_func_result':
database.c:285: error: 'sqlite3_int64' undeclared (first use in this function)
database.c:285: error: syntax error before 'long'
make: *** [database.o] Error 1

In the README.rdoc file of the gem I read about "enabling the option SQLITE_ENABLE_COLUMN_METADATA (see www.sqlite.org/compile.html for details)" but did not understand what should be done.

Can anyone please help me solve this issue?

I have tried other approaches such as Error with MySql while doing Bundle Install and I can't install sqlite3 gem but these did not work for me.

Update: I have similar issues when trying

rails new app1 -d mysql

create  vendor/plugins/.gitkeep
run  bundle install
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.1.3/lib/rails/generators/app_base.rb:232: warning: Insecure world writable dir /usr/local in PATH, mode 040777
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler.rb:209: warning: Insecure world writable dir /usr/local in PATH, mode 040777
Fetching source index for http://rubygems.org/
Installing rake (0.9.2.2) 
...
Installing jquery-rails (1.0.19) 
Installing mysql2 (0.3.11) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/username/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    ... (list of switches)

Gem files will remain installed in /Users/username/a/app1/vendor/bundle/gems/mysql2-0.3.11 for inspection.
Results logged to /Users/username/a/app1/vendor/bundle/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
An error occured while installing mysql2 (0.3.11), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

I already have the gem mysql2 (0.3.11) installed.

Update 2: When executing

gem update

I am getting the following when the sqlite3-ruby gem is being updated:

Updating sqlite3-ruby
Building native extensions.  This could take a while...
/Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/ext/builder.rb:48: warning: Insecure world writable dir /usr/local in PATH, mode 040777
ERROR:  Error installing sqlite3-ruby:
    ERROR: Failed to build gem native extension.

        /Users/username/.rbenv/versions/1.9.3-p0/bin/ruby extconf.rb
checking for sqlite3.h... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
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
compiling backup.c
compiling 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:79: error: 'SQLITE_OPEN_READONLY' undeclared (first use in this function)
database.c:81: warning: implicit declaration of function 'sqlite3_open_v2'
database.c: In function 'set_sqlite3_func_result':
database.c:285: error: 'sqlite3_int64' undeclared (first use in this function)
database.c:285: error: syntax error before 'long'
make: *** [database.o] Error 1


Gem files will remain installed in /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.5 for inspection.
Results logged to /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sqlite3-1.3.5/ext/sqlite3/gem_make.out
Gems updated: activesupport, activemodel, rack, journey, sprockets, actionpack, railties, coffee-rails, jquery-rails, minitest, rubygems-update, sass-rails
Installing ri documentation for activesupport-3.2.0.rc2...

Thanks

Community
  • 1
  • 1
Usering
  • 143
  • 3
  • 20
  • What version is sqlite? `sqlite3 --version` – ian Jan 06 '12 at 22:16
  • May I ask the stupid question - whats wrong with doing `gem install sqlite3` ? Is that too easy? ;) Btw, there's no dependence on XCode with gems (unless they specify it). – ian Jan 06 '12 at 22:24
  • @Iain With gem install sqlite3 I am getting ERROR: Error installing sqlite3: ERROR: Failed to build gem native extension. and then the above errors from "database.c: In function 'initialize':" down. – Usering Jan 06 '12 at 22:28
  • Would you paste up your PATH and the the path to sqlite3 ? – ian Jan 06 '12 at 22:38
  • @Iain using the which command: sqlite3 is /usr/bin/sqlite3 and using gem environment: GEM PATHS: - /Users/username/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1 - /Users/username/.gem/ruby/1.9.1 – Usering Jan 07 '12 at 07:34
  • I meant your main env path just to see if sqlite is in there, as you've 3.7.9 I'm guessing you compiled it yourself and aren't using the system one anymore? The `which` is giving the system one though (or did you overwrite it?) And the path to the sqlite3 gem can be helpful to do installs with the following syntax `gem install sqlite3 -- --with-sqlite3-dir=/usr/bin/sqlite3`, but like I say, I'm unsure that's the right path. MySQL gem install has lots of its own problems so that might be a red herring. – ian Jan 07 '12 at 16:59
  • @Iain I sym-linked /usr/bin/sqlite3 to the v3.7.9 I installed. After I did gem update, everything seems to be working as expected. I still cannot figure out why though. Thanks for your help. – Usering Jan 08 '12 at 09:03

1 Answers1

2

If you are running Mac OS 10.5.X or below, you can't run sqlite3. You need at least Snow Leopard to be able to compile it.

Instead try changing your Gemfile to use sqlite3-ruby 1.2.5

gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
Eruant
  • 1,816
  • 2
  • 14
  • 22