Reputation: 4716
I wanna create myApp using command
rails new myApp
but it gives an error:
Installing sqlite3 (1.3.4) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb checking for sqlite3.h... no sqlite3.h is missing. Try 'port install sqlite3 +universal' or 'yum install sqlite3-devel' and check your shared library search path (the location where your sqlite3 shared library is located). * 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 --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/ruby1.8 --with-sqlite3-dir --without-sqlite3-dir --with-sqlite3-include --without-sqlite3-include=${sqlite3-dir}/include --with-sqlite3-lib --without-sqlite3-lib=${sqlite3-dir}/lib --enable-local --disable-local
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.4 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.4/ext/sqlite3/gem_make.out An error occured while installing sqlite3 (1.3.4), and Bundler cannot continue. Make sure that
gem install sqlite3 -v '1.3.4'
succeeds before bundling.
What should I do? Thanks
Upvotes: 4
Views: 3961
Reputation: 36
I had the same issue but in Windows.
I found only two solutions for now
1* After the project creation fail, enter in its folder and modify the Gemfile.
Change the line
gem 'sqlite3', '1.3.11'
by one of these bellow:
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby", branch: "add-gemspec"
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
And run again the bundle install
command for this project
The second solution I found was downloading the gem from https://rubygems.org/ and saving it locally to install from file, first, you've to install mingw (but only for Windows)
C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn
C:\Sites>gem install --local C:\sqlite3-1.4.0.gem
I've tried some others solutions but these two were the only ones worked for me.
https://mycodeissuesandfixes.blogspot.com/2019/02/ruby-on-rails-issue-about-sqlite-3-gem.html Those are others fixes but I don't know if they're going to help you in Linux. Hope it helps!! I've been trying for 5 days completes until I found something that works with this error of sqlite 3 gem
Upvotes: 1
Reputation: 2929
I've found it pretty helpful to run this command whenever I install rails anew on Ubuntu. This normally takes care of the super common zlib and sqlite3 errors.
/usr/bin/apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev
Upvotes: 3
Reputation: 16284
Make sure you have the development headers for SQLite3 installed.
For example:
On Ubuntu, you can use apt-get install libsqlite3-dev
On Mac with homebrew installed: brew install sqlite
.
Upvotes: 12