Error Installing SQLite3 Gem via Bundler

Error installing sqlite3 gem via bundler

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

.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

Then run:

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

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

Error with sqlite3 when running bundle install

So I found the solution: Simply (manually) uninstall any existing versions of sqlite3 in your computer. What I did was:

  1. Run which -a sqlite3 to find out the directories in which sqlite3 was installed (for me there were 4 versions O.o). Delete all those sqlite3 files (by rm)
  2. Manually delete all the sqlite-related files in /usr/local/lib, usr/local/bin and usr/local/include
  3. After all the deletion, run bundle install again in your app dir, and the required version of sqlite3 will automatically be installed.

    $bundle install
    Fetching gem metadata from https://rubygems.org/..........
    Resolving dependencies...
    // Using a bunch of gems
    Installing sqlite3 1.3.10
    Installing turbolinks 2.5.3
    Installing uglifier 2.7.0
    Installing web-console 2.0.0
    Your bundle is complete!
    Use 'bundle show [gemname]' to see where a bundled gem is installed.

I hope this saves some of your time, if you encountered the same problem as I did. Thanks!

cannot install sqlite3 using gem

The system is missing ruby dev files. If you are using Debian

sudo apt-get install ruby-dev

should do the work.

Install ruby-dev using your package managers. (package name may differ across different linux distros)

Rails - error An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue

For multiple buildpacks, remove all of them and then set the Ruby one:

$ heroku buildpacks:clear
$ heroku buildpacks:set heroku/ruby

About SQLite on Heroku:

SQLite runs in memory, and backs up its data store in files on disk.
While this strategy works well for development, Heroku’s Cedar stack
has an ephemeral filesystem. You can write to it, and you can read
from it, but the contents will be cleared periodically. If you were to
use SQLite on Heroku, you would lose your entire database at least
once every 24 hours.

So, for the message

sqlite3.h is missing. Try 'brew install sqlite3'`

replace the sqlite3 gem for pg in your Gemfile, then edit the database.yml file:

# Gemfile
gem 'pg'

# config/database.yml
default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000

development:
<<: *default
database: your_project_name_dev

test:
<<: *default
database: your_project_name_test

production:
<<: *default
database: your_project_name_prod

Probably you'll need to clean the tmp/ folder, so you can delete the Gemfile.lock file and run the rails commands for that:

$ rm -rf Gemfile.lock
$ rails tmp:clear
$ rails tmp:create


Related Topics



Leave a reply



Submit