- 1 year ago
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. for SQlite3
The error message you encountered, "Gem::Ext::BuildError: ERROR: Failed to build gem native extension" while installing the sqlite3
gem, typically occurs when there are missing dependencies or configurations required to build the native extension of the gem.
To resolve this issue, follow these steps based on your operating system:
On Windows:
Install the Ruby+Devkit:
- Download the Ruby+Devkit installer from the RubyInstaller website: https://rubyinstaller.org/downloads/
- Run the installer and choose the option to "Add Ruby executables to your PATH."
- Complete the installation.
Install SQLite development libraries:
- Download the SQLite3 development kit (SQLite3 DLL, headers, and import library) from the SQLite website: https://www.sqlite.org/download.html
- Extract the downloaded ZIP file.
- Copy the
sqlite3.h
andsqlite3ext.h
header files to theinclude
directory in your Ruby installation directory. - Copy the
sqlite3.lib
import library to thelib
directory in your Ruby installation directory. - Copy the
sqlite3.dll
file to thebin
directory in your Ruby installation directory.
Install the
sqlite3
gem:Open the command prompt or PowerShell as an administrator (to ensure elevated privileges).
Run the following command to install the
sqlite3
gem:bashgem install sqlite3 --platform=ruby
On macOS and Linux:
Ensure you have the SQLite development libraries installed on your system. On Ubuntu/Debian, you can install them with:
bashsudo apt-get update
sudo apt-get install libsqlite3-dev
Install the
sqlite3
gem:bashgem install sqlite3
After completing the above steps, try installing the sqlite3
gem again. It should build successfully without any errors. If you encounter any other issues, please make sure you have the necessary build tools and dependencies for building native extensions installed on your system.