Unable to install MySQL2 gem on Windows 7 - ruby-on-rails

I am getting the following error message while installing, let me know if I need to post more details.
I followed instructions from the following location:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
I am using ruby 1.9.2p136 (2010-12-25) [i386-mingw32].
Here is what I get:
E:\work_desk\trunk>gem install mysql2 -v 0.2.4
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
C:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for main() in -llibmysql... 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
--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=C:/Ruby192/bin/ruby
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
2.4 for inspection.
Results logged to C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.4/ext/mysql2/ge
m_make.out

The specific version of mysql2 gem you're trying to install (0.2.4) not only lacks binaries for Windows, but have issues on Windows.
Please install mysql2 gem without indicating the version:
gem install mysql2
Which will install latest version (0.2.6 at the time of my posting this) and also provides binaries for Windows which skip the compilation step.
If you still want to force the compilation (because your version of MySQL differs from the one used to generate the binary gem, you will need to install RubyInstaller's DevKit from RubyInstaller website:
http://rubyinstaller.org/downloads
And follow the DevKit installation instructions from our wiki (that is linked from the download page)
You will need to provide the path to both headers and libraries during the gem installation process, and adjust the MySQL installation location from the following instructions:
subst X: "C:\Program Files (x86)\MySQL\MySQL Server 5.1"
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt
subst X: /D
The above command uses subst to avoid issues with path with spaces, which you should avoid always.
Hope this helps.

After searching around for a way to make it work, I finally got it installed with the following on the command prompt:
gem install mysql2 -v 0.2.6
With the following results:
Fetching: mysql2-0.2.6-x86-mingw32.gem (100%)
Successfully installed mysql2-0.2.6-x86-minw32
1 gem installed
Installing ri documentation for mysql2-0.2.6-x86-mingw32...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6-x86-mingw32...
Enclosing class/module 'mMysql2' for class Client not known
Try it. It should work.

If still not able to install mysql2 gem on windows7 or not very clear on the steps to follow, then please go through this post which will help you in step-by-step installation -
http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html
And for mysql_api.so error (C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql-2.8.1-x86-mingw32/lib/1.9/mysql_api.so), copy "libmySQL.dll" file from C:\Program Files\MySQL\MySQL Server 5.1\bin to C:\Ruby192\bin
Path of installation may vary, for details refer to this post - http://rorguide.blogspot.com/2011/03/getting-error-specified-module-could.html.
Hope, this will help you in sorting out your issues.

Start with RailsInstaller.
This is assuming you are running the mysql server locally (local development), and your Ruby is compiled 32-bit. (Check ruby -v. x64 || i386.)
Download the mysql-community-web-installer. In the top right select 32-bit. You pretty much just need the Server. The Workbench is handy also.
The gem command needs a path without spaces, so use subst:
subst X: "C:\Program Files (x86)\MySQL\MySQL Server 5.6"
gem install mysql2 -v=0.3.13 --platform=ruby -- --with-mysql-dir=X:
You will need libmysql.dll in the PATH -- the easiest thing is just to copy it to Ruby's bin directory:
copy "C:\Program Files (x86)\MySQL\MySQL Server 5.6\lib\libmysql.dll" "C:\RailsInstaller\Ruby2.0.0\bin"
NOTES
Don't do this from PowerShell! (DevKit has trouble changing path info in powershell.)
Make sure all libraries are 32-bit, since RailsInstaller's ruby etc. are all compiled 32-bit and need to link to 32-bit libraries.
If you don't want a server locally, just install the C Connector, and do these instructions with that directory and libmysql.dll. Don't mix and match -- make sure the .dll matches the version you compiled the gem against.

From this:
checking for main() in -llibmysql... no
it looks like you haven't installed the MySQL drivers and apps. If so, were they allowed to install into their default locations? At a minimum you'll want the client software if the server is running on a different machine.

install 32 bit mysql connector/c get it at here
copy libmysql.dll from the directory that you install the connector/c to the %installed ruby directory%/bin/
then reinstall the gem again.

I've tried the solution of #Mrk Fldig but it didn't work...
So what solved the problem was:
Downloaded the lastest MySQL Installer for windows 7 32 bits
Installed the gem with the following command: gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:/Program Files/MySQL/MySQL Connector C 6.1 6.1.2/"'
One pitfall to be aware of is that I changed the backslashes (\) to normal slashes (/). I've tried the same procedure with backslashes and it didn't work.
The installer already includes the C connectors for MySQL at MySQL Connector C 6.1 6.1.2 directory. Therefore, passing only the --with-mysql-dir parameter without the --with-mysql-lib or --with-mysql-include parameters, makes the gem to look at the same directory for the lib and include directories

Related

RMagick installs using devkits msys.bat but not using gitbash

(I am using Windows 8)
I finally got the rmagick gem to install by opening the msys.bat file in my Devkit folder using this command
gem install rmagick --platform=ruby -- --with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include
This is the output
Building native extensions with: '--with-opt-lib=c:/imagemagick/lib --with-opt-i
nclude=c:/imagemagick/include'
This could take a while...
Successfully installed rmagick-2.15.0
Parsing documentation for rmagick-2.15.0
Done installing documentation for rmagick after 6 seconds
1 gem installed
But when I run the same exact command using gitbash I get this error:
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include'
This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
c:/RailsInstaller/Ruby2.1.0/bin/ruby.exe extconf.rb --with-opt-lib=c:/imagemagick/lib --with-opt-include=c:/imagemagick/include
Invalid drive specification.
Unable to get ImageMagick version
*** 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=${opt-dir}/include
--with-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/RailsInstaller/Ruby2.1.0/bin/ruby
extconf failed, exit code 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/rmagick-2.15.0 for inspection.
Results logged to c:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/extensions/x86-mingw32/2.1.0/rmagick-2.15.0/gem_make.out
I get this same exact error when running bundle install using gitbash and when I try to run bundle install using msys.bat I get the same error but its a bit longer and complains about development tools.
If it works using msys.bat, what do I need to change to get it to work with gitbash and with bundle installs?
EDIT: I did the same command using msys.bat but specified rmagick -v '2.13.3' and bundle install worked. My gemfile doesn't specify a version so not sure why 2.15.0 didn't work. Anyways things are working...so far. But I do think I should think about switching from windows like the first comment suggests due to all the problems I've faced so far with windows.

Cannot install pg gem in Mavericks with Postgres.app

I am trying to install the pg gem for use with Postgres.app on my local machine. I am running Mavericks.
Postgres.app is installed and running fine, but I cannot get the gem to work. I've done the following:
Used the command 'env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config' from the Postgres.app documentation
Updated Homebrew and installed the Apple GCC 4.2
Installed the Xcode developer tools
Updated my $PATH to reference both the Postgres.app bin and lib directories
All with no success. Here is the specific error message I receive:
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/MacOS/bin/pg_config
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
sh: /Applications/Postgres.app/Contents/MacOS/bin/pg_config: No such file or directory
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
--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=/Users/Brian/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
--with-pg
--without-pg
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/
I'd appreciate any help you can offer. Thanks!
You probably have the wrong path for --with-pg-config, check if it's actually there.
You can find the correct path to pg_config with:
find /Applications -name pg_config
In the latest Postgres.app Version the path is:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
In my case (running Postgres.app v9.3.4.2) it only seemed to work when prepending the environment architecture flags:
env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Being on a brand new mac, here's what I had to do:
Install Xcode tools from the app store
Open Xcode tools and accept the license
Now run (hopefully a future-proofed command):
version=$(ls /Applications/Postgres.app/Contents/Versions/ | tail -1)
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/$version/bin/pg_config .
If you have trouble, you can troubleshoot a bit by checking out the actual error in the mkmf.log which you can find by running (if using rvm):
cd ~/.rvm ; find . -name mkmf.log | grep pg
I was able to install pg with this command
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
I found my path by running
sudo find / -name "pg_config"
and I Successfully installed pg-0.17.1
adding the postgress bin dir to the path also does the trick. just add the bin to the pat like this. with recent installs the latest symbolic link makes sure that this path should be 'stable' for future version upgrades.
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
To resolve this issue I installed postgres using homebrew using the following in the terminal window:
brew install postgres
Homebrew can be found here
http://brew.sh
This worked for me:
gem install pg -- --with-pg-config=`which pg_config`
For future reference, since a lot of us are posting new paths for the new version numbers:
Currently I'm seeing a symlink called latest in /Applications/Postgres.app/Contents/Versions/.
You should be able to just do:
$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
And forget about the version number. This might not apply to every (older) version, but I myself was looking for a snippet I could save and reuse.

Getting Ruby on Rails environment working and installing sqlite3

Trying to upgrade to the latest version of Ruby on Rails. I got ruby and rails installed ok (I think).
C:\Users\benjaminw>ruby --version
ruby 2.0.0p0 (2013-02-24) [x64-mingw32]
C:\Users\benjaminw>rails -v
Rails 3.2.13
I'm following an instructional guide out of a Ruby on Rails book but it's a little out of date. The next step says to download the sqlite3 db and extract the the files to the following folder C:/Ruby200/bin
Then run the following command to make sure the db was installed correctly
C:\Users\benjaminw>sqlite3 --version
3.7.16 2013-03-18 11:39:23 66d5f2b76750f3520eb7a495f6247206758f5b90
Here is where the problem arises. When I enter the next command I get an ERROR and it seems like it's important to setting up the environment properly. Does anyone know what the following means and how to fix it? Oh and I installed this version of the devkit on my windows 7 computer DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe.
C:\Users\benjaminw>gem install sqlite3-ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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=C:/Ruby200/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/
--enable-local
--disable-local
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1
.3.7 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/sqlite3-1.3.7/ext/sqlite3/
gem_make.out
Running rails in a lousy environment will make things a bigger headache for you. Dependencies will conflict with your only ruby version and make you consider re-installing your OS.
It looks like you are using Windows. I installed rails 3.2 on a fresh Windows 8 computer. After a few days of dealing with config files randomly throughout windows filesystem I grabbed an old laptop installed Ubuntu OS (only because UEFI prevented me from formatting windows 8 and installing ubuntu).
Do yourself a favor! Get an installation of Ubuntu. It makes it way easier to learn Ruby and Rails because the files aren't littered across a mess of windows folders.
To finish, learn about RVM or RBENV. They will make your life better by installing easily and switching versions even easier. There are other benefits that are just to off-topic.
RVM Install <- Personal choice, but I haven't tried RBEnv.
RBEnv on Github
Installing Rails for the first few times is a headache. If you install with one of the above options hopefully it will only be one headache.
I absolutely have had no problems with Ruby 2.0 and SQLite as a result of compiling SQLITE.h
Solution
Go the following URL to have this issue squared away by someone who took the next step of compiling the gem over the pre-compiled gems for other Rails 4 Rubyists who wish to use Windows: this link.
With a command like -with-opt-dir=<Path of Sqlite.3 bin, lib, include, and share folders> command. The only tricky part was the files the official sqlite3 website provides are precompiled, which can be extremely hard to consider that being the problem.
I can give you further instructions if you still have any trouble doing such actions towards using Ruby 2.0 and Rails 4.0.0.0beta1.
Using Ruby 2.0 with Windows should be perfectly fine for you now regarding Sqlite3 and Rails. Do note to avoid Ruby 2.0 64-bit when it comes to Rails 4.0.0beta1 because one of the dependent gems for Rails 4 flags incorrectly that the cpu of your computer is not compatible with its gem requirements; that's being resolved soon.
Edit: Noticed I wasn't as helpful as I should have with more explicit instructions; Have provided you a link by someone who's already taken the time to do so and the files needed to get up and running.
#Brian Petro : Actually, solving this issue is easy if you know how Gems and .h files at the end of the day works sometimes with the construction of them. The issue is rooted from how some gems are handled with Ruby 2.0; starting with Ruby 2.0 precompiled gems that were convenient for previous versions of Ruby won't work if they have ABI Breakage; Sqlite3 gem is one of them:
Did you see the topic in the rubyinstaller google group, New Knapsack package: sqlite (experimental), you can use the new package and install the gem.
I can success install the gem, you can refer to the following topic:
SQLite3 Ruby 2.0 on Windows
My environment:
OS: win 7 64bit
Ruby: ruby 2.0.0p247 (2013-06-27) [i386-mingw32]
Gem: 2.0.5
Have you tried http://railsinstaller.org/? From their site: "RailsInstaller has everything you need to hit the ground running. In one easy-to-use installer, you get all the common packages needed for a full Rails stack. Download it now and be writing (and running) Rails code in no time." Looks like it includes sqlite.
This link will help.
First install libsqlite3-dev then try sqlite3 using gem.
Use package manager for libsqlite3-dev
and
sudo gem install sqlite3

Can't install pg gem on Windows

I've got 2 Ruby versions: 1.8.7 and 1.9.2 and PostgreSQL 8.3. I cant install pg gem on any of them. Getting this error:
C:/Development/Ruby187/bin/ruby.exe extconf.rb
checking for pg_config... yes
not recorded
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=C:/Development/Ruby187/bin/ruby
--with-pg
--without-pg
--with-pg-config
--without-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
I know it's a common problem, but I haven't found any working solution yet... Oh, I have added C:\Program Files (x86)\PostgreSQL\8.3\bin to my PATH.
The message you're getting is a clear indication that you lack something for the correct installation of that gem:
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.
There is no Windows native version of latest release of pg (0.10.0) released yesterday, but if you install 0.9.0 it should install binaries without issues.
Anyhow, if you want to install the gem, you need a build environment installed. If you're using RubyInstaller, then you need the DevKit
Installation of the gem will only require you provide additional options to gem installation (like --with-pg-dir)
subst X: "C:\Program Files (x86)\PostgreSQL\8.3"
gem install pg -- --with-pg-dir=X:
subst X: /D
PsAdding for linux users.
I solved this error installing libpq-dev.
I fought this for two days. I do my rails command line stuff from the excellent unixy like command window provided by msysgit. I created a postgresql-path.bat file that contained
#set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3\bin
#set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3\include
#set PATH=%PATH%;C:\Progra~1\PostgreSQL\8.3
At the top of the msys.bat file I added
CALL postgresql-path.bat
As soon as I got the space out of my PATH variable for the postgreSQL directories my problems installing 'pg' went away. Hope this saves somebody the problems I had.
After nearly two days of trial and error (and thanks in a large part to the advice of the earlier post in this thread and elsewhere, I was able to successfully install pg 0.10.0 in Ruby 1.8.7 (for both my RubyInstaller and my InstantRails versions). In case anyone encounters this problem again, I'll summarize my final successful installation process.
First, I had to install DevKit, following their installation instructions. I had to copy (for safety) and then delete the operating_system.rb file in \Ruby187\lib\ruby\site_ruby\1.8\rubygems\defaults folder in order for the installation to run successfully.
Secondly, I installed the rake-compiler, and rdoc gems.
gem install rake-compiler
gem install rdoc
(If you have problems with either of them, I'd recommend a liberal use of the --platform=win32 configuration option)
Once those were installed successfully, the final installation of pg itself was:
gem install pg --platform=mswin32 --version=0.9.0 -- -- with-pg={Postgres directory short name}\
e.g.
gem install pg --platform=mswin32 --version=0.9.0 -- -- with-pg=C:\PostgreSQL\
The final '\' seems to be necessary for the way the installer parses directory strings. I realize my use of configuration options may be a little more than necessary, but an apparently successful install of version 0.10.0 (when I excluded the --version option) did not actually work.
Thanks again to those in this thread who helped me to this sequence.
"gem install pg" not working
Fetching: pg-0.17.0.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
Try this it worked for me and I am pretty sure it will work for you as well::
#On Ubuntu
$ sudo apt-get install postgresql-client libpq5 libpq-dev
$ sudo gem install pg
This should work with "Bash on Ubuntu on Windows" as well
First install ruby DevKit
On Windows XP and from MSysGIT bash terminal just do the following
based on my installation path
subst X: "D:/Program Files/PostgreSQL/9.0"
gem install pg -- --with-pg=X:
My gem pg-0.10.1 got installed successfully.
This may seem like a no brainer, but I had this same error with a slight twist. After getting the build to find the headers, it immediately failed and claimed to be unable to find libpq. I finally deduced that I was trying to build against a 64-bit postgres install with a 32-bit ruby. Installing the 32-bit postgres resulted in an instant-fix. Just thought I'd add this in case anyone else with the same error stumbles across this thread.
The message "Can't find the 'libpq-fe.h header" means that installer can't find the header
Check that your Postgre installation contains development tools ("include" folder). Install postgre development tools in case of absence.
Check location of pg_config.exe. You need run installation like
gem install pg -- --with-pg-config="C:/PROGRA~2/POSTGR~1/8.3/bin/pg_config.exe".
Note that you need to use short folder names.
To build a native extension for pg gem you need a ruby DevKit (http://rubyinstaller.org/downloads/)
I meet another problem:
D:\app1>rake test
(in D:/app1)
rake aborted!
no such file to load -- 1.9/pg_ext
In this case you need manually copy copy content of
C:\Ruby\192\lib\ruby\gems\1.9.1\gems\pg-0.10.0\lib\
to
C:\Ruby\192\lib\ruby\gems\1.9.1\gems\pg-0.10.0\lib\1.9
Thanks Luis! pg 0.9.0 installed just fine.
For the latest version (0.10.0) you need the devkit and this command "gem install pg -- --with pg-dir=path/to/your/postgresql/dir"
When I leave the additional "--" away, it gets me an error:
"gem install pg --with-pg-dir=C:/postgresql/9.0"
I had the same problem.
You most likely have a perl installation in your path before PostgreSQL. The most common perl installation for Windows has an executable name pg_config in its bin which causes conflicts.
pg v0.10.0 installs just fine with rubyinstaller + devkit as long as you specify paths without spaces (e.g. C:/PROGRA~) -- otherwise nmake chokes.
Windows 7, PostgreSQL 8.4, Ruby 1.9.2:
subst X:\ "C:\Program Files\PostgreSQL\8.4"
gem install pg -- --with-pg=X:/
This installed it successfully.
Other easy way, on windows
Install postgresql ODBC.
Copy libpq.dll from the pgqlODBC lib directory
Paste it into PostGreSQL lib directory
Run this command (adapt the PostGreSQL path in this command, according to yours) :
gem install pg -- --with-pg-config="C:\Dev\Databases\PostgreSQL\9.0\bin\pg_config.exe"
install postgresql per pacman:
ridk exec pacman -S mingw-w64-x86_64-postgresql
then do
bundle install
I had the same problem.
The following worked for me. Hope this helps to you.
Versions:
Windows 10 version 10.0.19043.1165.
PostgreSQL Server 13.
Ruby DevKit 3.0.2-1 (x64).
Administrator prompt: C:\Ruby30-x64> subst X: "C:\Program Files\PostgreSQL\13\bin"
Administrator prompt: C:\Ruby30-x64> gem install pg -- --with-pg-dir=X: --with-pg-include="c:\Program Files\PostgreSQL\13\include" --with-pg-lib="C:\Program Files\PostgreSQL\13\lib"
I ran into the same problem. I wanted to access a postgres database using dbi and had to install Pg.
It took me a day to successfully compile the module with instructions similar to the other posts of this thread. But the second time I had to do it, I found another solution: using ODBC.
Install the ODBC driver for postgresql (http://www.postgresql.org/ftp/odbc/versions/)
Configure the data source (http://www.xtuple.org/SettingUpPostgresAndOdbc)
Install the ruby dbi and odbc gems
gem install dbi
gem install ruby-odbc
gem install dbd-odbc
Connect to postgres
require 'dbi'
dbh = DBI.connect('dbi:ODBC:DSN_NAME', 'USER', 'PASS')
This worked for me using ruby 1.9.1 on Windows XP 32 bit.
Also, this doesn't change anything in your code except the DBI.connect line, if you were already using DBI.
PostgreSQL 9.0:
gem install pg --platform=mswin32 --version=0.9.0 -- '--with-pg="C:\Progra~1\PostgreSQL\"'
note the single-tick encapsulation. (~1 signifies "Program Files", change to ~2 if PostgreSQL is in Program Files (x86) on Win64)
As of version 0.13.0 of the pg gem, you should be able to install it using something like the following:
subst X: "C:\Program Files\PostgreSQL\9.0"
gem install pg -- -- with-pg=X:
subst X: /D
Then you can successfully run bundle install and see the following line in the output:
Using pg (0.13.0)
instead of the errors.
I got it:
AND THE MAGIC TRICK :
is that you do not have this installed -- > postgres-devel
so go get it :
install postgresql-devel
Thats all... than just gem install pg and there it goes.

Problem in SQLite3 installation

The following error comes up:
C:\gem>gem install sqlite3-ruby --local
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for #include <sqlite3.h>
... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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
--srcdir=.
--curdir
--ruby=C:/Ruby/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1
.3.0 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.3.0/ext/sqlite3/
gem_make.out
I have copied all the necessary files required in the Ruby/Bin folder, still it keeps reporting this error that sqlite3.h is missing.
Please do tell where do I have to place sqlite3.h, when I am installing the gem locally as you can see and I am currently using 1.3.0 version of SQLite3 for its installation.
I have tried with the solutions that were posted for similar problems. And I am using Windows XP.
Thanks in advance.
I had this problem. This is the solution I found. It's not very pretty, but it worked for me. In my case, I was using cygwin. There's probably a similar way to do it without using cygwin, but I don't know how.
1) Download the source of SQLite. I went for SQLite 3.6.23, somewhat arbitrarily, via this URL:
http://www.sqlite.org/src/info/4ae453ea7b
If that doesn't work, then go to the release timeline at http://www.sqlite.org/src/timeline?n=200&t=release&y=ci , choose a release, and download the ZIP file of it.
2) Unpack the ZIP archive somewhere. Go to that directory in cygwin. Execute these commands:
./configure
make
make sqlite3.dll
make install
3) Copy the sqlite3.exe and sqlite3.dll from the directory where make created them into somewhere on your path.
4) Once that's done, gem install sqlite3-ruby finally worked.
I was following this guide: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/240902
I know this has been closed for a while but I was having the same issue and this
helped. Install apt-cyg. First install subversion and wget through the standard
cygwin setup program. Then run the following commands:
wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
Now using apt-cyg install the sqlite3 development:
apt-cyg install libsqlite3-devel
and finally
$ gem install sqlite3-ruby
Building native extensions. This could take a while...
Fetching: sqlite3-ruby-1.3.3.gem (100%)
#######################################################
Hello! The sqlite3-ruby gem has changed it's name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
Thanks from the Ruby sqlite3 team!
<3 <3 <3 <3
#######################################################
Successfully installed sqlite3-1.3.6
Successfully installed sqlite3-ruby-1.3.3
2 gems installed
Installing ri documentation for sqlite3-1.3.6...
Installing ri documentation for sqlite3-ruby-1.3.3...
Installing RDoc documentation for sqlite3-1.3.6...
Installing RDoc documentation for sqlite3-ruby-1.3.3...
I got it working by following these suggestions: http://www.skorks.com/2009/08/installing-and-using-sqlite-with-ruby-on-windows/
Basically you can download from sqlite.org, the DLL and shell file and make sure you copy the DLL in each of the ruby versions you have installed, in their /bin directory. You can place the shell file somewhere in your system path, I have a folder c:\bin. Then you can install pik gem install sqlite3
replace with sqlite3 (1.3.10-x64-mingw32) in Gemfile.lock worked for me.

Resources