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
Related
I'm upgrading an existing setup to use Rails 5 beta 3. As part of that, I've upgraded Ruby to version 2.2.4 (using RVM), i.e.
rvm install 2.2.4
rvm use 2.2.4
With that done, I'm trying to install the Rails gem. However, running
sudo gem install rails
gives me the error
ERROR: Error installing mime-types-data: mime-types-data requires Ruby version >= 2.0.
Having read this question, I've looked at my Ruby versions:
ruby --version => ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
sudo ruby --version => ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
I don't seem to be able to access RVM from sudo, so I tried using gem install rails instead, which also fails while building native extensions:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/ubuntu/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20160405-31973-l7bzq7.rb extconf.rb
checking if the C compiler accepts ... *** 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=/home/ubuntu/.rvm/rubies/ruby-2.2.4/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /home/ubuntu/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:336:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /home/ubuntu/.rvm/gems/ruby-2.2.4/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/ubuntu/.rvm/gems/ruby-2.2.4/extensions/x86_64-linux/2.2.0/nokogiri-1.6.7.2/gem_make.out
I see two solutions to this:
Upgrade the Ruby that's used in sudo commands to 2.0 or above (preferably 2.2.4). I can't figure out how to do this, because sudo rvm results in command not found for rvm.
Fix the error that comes up when using gem install rails. Again, I don't know how to do this.
Which of these is the easiest (or is there an easier fix), and how do I do it?
It looks like you have installed RVM in single user mode. This is the reason why sudo rvm returns command not found error. You can find more about RVM modes here: https://rvm.io/rvm/install#2-load-rvm-into-your-shell-sessions-as-a-function.
But, based on log your provided, the error is in installing Nokogiri. Please install development header files first with command sudo apt-get install ruby-dev zlib1g-dev liblzma-dev. For details follow: http://www.nokogiri.org/tutorials/installing_nokogiri.html
The sudo command that you invoke will be executed as the root user, hence it won't load your profile settings (which is where the rvm ruby version is loaded, if it works like rbenv which is what I use, never used rvm)
On the other hand, whenever a Building native extensions fail when installing a gem it means that you need the development packages (C/C++ header files) for a library that is the one that actually does the whole thing (ruby gems are usually wrappers around it), so for instance, if you want to build ruby you will need the ruby development package from your linux distribution (or from brew if you use OSX), the development package from postgres to build pg gem, etc.
I've seen very similar problems in other SO questions (e.g. No source for ruby-1.9.2-p321 provided with debugger-ruby_core_source gem) as well as through a Google search, but none of those have helped so far.
I'm using OSX Mavericks (first time mac user) and rbenv (first time using that too). I've git cloned a Rails project which I've previously ran on another laptop (Ubuntu & rvm) fine.
rbenv version: 2.0.0-p451 (which I manually installed)
When I try to bundle install, I get the following:
...
Using debugger-ruby_core_source (1.3.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/macuser/.rbenv/versions/2.0.0-p451/bin/ruby extconf.rb
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
checking for rb_method_entry_t.called_id in method.h... no
checking for rb_control_frame_t.method_id in method.h... no
Makefile creation failed
**************************************************************************
No source for ruby-2.0.0-p451 provided with debugger-ruby_core_source gem.
**************************************************************************
*** 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=/Users/macuser/.rbenv/versions/2.0.0-p451/bin/ruby
--with-ruby-dir
--without-ruby-dir
--with-ruby-include=${ruby-dir}/include
--with-ruby-lib
--without-ruby-lib=${ruby-dir}/
Gem files will remain installed in /Users/macuser/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/debugger-1.6.5 for inspection.
Results logged to /Users/macuser/.rbenv/versions/2.0.0-p451/lib/ruby/gems/2.0.0/gems/debugger-1.6.5/ext/ruby_debug/gem_make.out
An error occurred while installing debugger (1.6.5), and Bundler cannot continue.
Make sure that `gem install debugger -v '1.6.5'` succeeds before bundling.
So I then tried running gem install debugger -v '1.6.5', which throws basically the same error as above.
From searching around, here's some things I've unsuccessfully tried:
rake add_source
bundle update debugger
Resetting gemfile.lock
gem install debugger-ruby_core_source
and probably some others too... but nothing seems to work.
Update: Switched my rbenv local environment to ruby 2.1.0 and it worked. Didn't fix the underlying problem, but this is fine I guess
Try install debugger without specifying a version and then run bundle install again.
I had the same error, and it just worked, don't ask me why:
$ gem install debugger
$ bundle install
I ran into what I believe was the same problem while trying to install dubugger with ruby 2.0.0-p598.
The gem debugger-ruby_core_source is a dependency of debugger and provides header files for specific versions of ruby that seem to be used while installing debugger. Look in debugger-ruby_core_source/lib/debugger/ruby_core_source/ to see which versions are supported—the header files are not provided for all ruby versions. In my case, they were not provided for version 2.0.0-p598.
Looking at the README for debugger-ruby_core_source, there is a rake task for adding the required files for ruby versions.
From the command line within the gem's directory, I ran
$ rake add_source VERSION=2.0.0-p598
When I ran this task the first time, I received an error and was required to install the archive-tar-minitar gem before running the rake task again.
After the rake task added the header files for my version, I was able to successfully install and run debugger.
I am posting here because absolutely nothing worked. The only solution that fixed the problem for me:
Even though we are installing debugger, the error is in installing a requirement, debugger-ruby_core_source.
If you look at the error that is exactly where it raises the issue.
No source for ruby-2.0.0-p451 provided with debugger-ruby_core_source gem.
It is actually quite easy to fix this error. Just run the below command, installing the dependencies, and retry:
gem install debugger-ruby_core_source
Credit for this solution to: FIXED gem install debugger -v ’1.6.2′ No source for ruby
The problem is that your Gemfile.lock lists an old debugger-ruby_core_source gem. That gem needs to know about your specific ruby version, to get the header files correctly, and if the version your bundle install is too old, it won't work.
The correct solution is to update your Gemfile.lock with a new version, by running
bundle update debugger-ruby_core_source
#delba's and #superuseroi's answers basically coming down to using gem to install the debugger-ruby_core_source gem directly from the source - which will pull the latest version, but fixing your bundle will be easier and will also persist in your source control (at least until you next upgrade your Ruby).
Also see this article about common Ruby gem issues
Debugger needs source of the Ruby to work.
So just reinstall the Ruby with source (not bin).
For example:
rvm reinstall 2.0.0 --disable-binary
Thanks all.
rvm list
rvm ruby-2.0.0-p451
Tried bundle install, got errors about not being able to install into non-bare repository, suggesting I remove cache directory; which I did:
rm -rf /usr/local/rvm/gems/ruby-2.0.0-p451/cache/
tried to
rvm gemsest use [my_gemset_name]
and got the same errors.
ended up using:
rvm gemset use default
and bundle install worked.
there seems to be a problem with the compatibility of ruby version and debugger gem of rails.
Running the below command worked for me:
rvm ruby-2.0.0-p481
If it doesn't work type
rvm list
will get a list of ruby version.
Select an older ruby version, which might work.
To solve this problem, you need reinstall rails' source code. This command will fix the problem:
$ rvm reinstall 2.0.0 --disable-binary
Then, the command $ bundle install will work.
Reference: https://pfonseca.com/error-to-install-debugger-s-gem
Use byebug gem instead of fix my problem very well.
I am new to Ruby and Rails, as well as all this command line melarky. So please bear with me.
I have installed, RubyGems, Homebrew, RVM, Rails etc, by following various tutorials.
I think I have all of this going now, but when I type:
rails --version
I get, 3.2.12. I notice that Rails 4 is out. How do I upgrade to this version?
If I do:
gem install rails
Even doing:
gem update rails
I still get 3.2.12.
Any ideas?
UPDATE
When trying a few options here, I get this message returned...
Michaels-MacBook-Pro:~ ParanoidAndroid$ gem install rails --version=4.0
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
*** 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/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/lib
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0'
from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:712:in `try_run'
from extconf.rb:26:in `<main>'
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/atomic-1.1.14 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/atomic-1.1.14/ext/gem_make.out
Seems there's an error happening. Any further ideas?
Thanks again everyone!
If you already have a Rails project you should:
Specify the desired version in your Gemfile (e.g. gem 'rails', '~> 5.2.0.rc1')
Run bundle install (bundle update may be needed)
Run rails app:update (rake rails:update for 4.2 and earlier)
Follow instructions on screen
Follow the official guide for additional steps depending on your version
If you are using RVM then you should create a seperate gemset first like:
rvm gemset create whateverName
in this example I will install rails 4
rvm install 2.0.0
rvm list
rvm 2.0.0
^^^^(you may need to copy and paste the version number exactly here as it was displayed in rvm list)
rvm gemset create rails4
rvm gemset use rails4
add the following to your gemfile for existing apps
gem 'rails', '4.0.0'
then run
bundle update rails
or do following to just install the gem
gem install rails --version=4.0
UPDATE
If you havne't installed Xcode 4.5 CLI tools then you will need to
Preferences > Downloads > Components
DMG
https://developer.apple.com/downloads
you may then also need to use homebrew to update gcc
brew install apple-gcc42
the following link has all the information you will need:
https://thoughtbot.com/blog/the-hitchhikers-guide-to-riding-a-mountain-lion
gem update rails does nothing for you, because bundler makes sure that only the gems specified in your Gemfile are loaded and used.
So in order to upgrade to Rails 4, you need to change the Rails version number in your Gemfile and run bundle update rails.
This Railscast guides you through all the steps of manually updating an existing application from Rails 3.2 to Rails 4:
http://railscasts.com/episodes/415-upgrading-to-rails-4
You can install either with specific version OR putting gem version in itself Gemfile.
gem install rails -v 4.0.0
You can get a list of all gem versions with
gem list rails --remote --all
To install specify version 4.0.1 for example you can use
gem install rails -v 4.0.1
Or you could just specify the version in your Gemfile
Best to use gem list --remote --all. Unless your looking for that particular version as long as the gemset for that project has been established
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
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.