How to fix gem install gtk2 in cygwin Ruby on Windows - ruby

I choose to use Cygwin for installing ruby on my system than using the usual rubyinstaller way.
Now, just as when I'm trying to install gems I usually use (like gtk2). It squeaks out some errors.
And here's the details: (I'm on Windows 8)
C:\Users\imraven>ruby -v
ruby 1.9.3p327 (2012-11-10 revision 37606) [i386-cygwin]
C:\Users\imraven>gem install gtk2
Building native extensions. This could take a while...
ERROR: Error installing gtk2:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
"C:/Program Files (x86)/git/bin/sh.exe": /usr/bin/ruby.exe: No such file or directory
Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/glib2-1.1.9 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/glib2-1.1.9/ext/glib2/gem_make.out
What should I do to fix this? The main reason why I'm opting for Cygwin's Ruby is that I wanted to use Process.fork method (which is unavailable from the normal RubyInstaller Windows version of Ruby)
Thanks! :)

You may have installed ruby for windows, and not the cygwin version.
Run the Cygwin setup, and choose Ruby, under the Ruby category. Also make sure that you've installed the gcc compiler and GNU make, under the Devel category, so that the gems can build the native extensions.

Related

Error installing jekyll: ERROR: Failed to build gem native extension

I use github+jekyll to build blog, i try to install jekyll to local(windows 10), while it failed when i rungem install jekyll and the stack trace is
C:\Developments\FrontEnd\rubygems-2.7.7>gem install jekyll
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
C:/Developments/FrontEnd/Ruby25-x64/bin/ruby.exe -r ./siteconf20180806-33956-l8y76h.rb extconf.rb
creating Makefile
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR=" clean
'make' is not recognized as an internal or external command,
operable program or batch file.
current directory: C:/Developments/FrontEnd/Ruby25-x64/lib/ruby/gems/2.5.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser
make "DESTDIR="
'make' is not recognized as an internal or external command,
operable program or batch file.
make failed, exit code 1
what i do is:
1. install ruby, path variable was set, version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32].
2. install rubygems, version: 2.7.7.
3. install MSYS2.
4. install jekyll, gem install jekyll, then the above error occurs and i'm not sure the reason.
i have tried to install devkit and it not works, i think my ruby version is 2.5+, so don't need devkit and i have uninstalled it.
Anyone could help me?
Although they made the Ruby+DevKit an "optional" download for the RubyInstaller on Windows, if you plan to install gems, it is practically a necessity. A large percentage of the most popular gems are C extension that will need built on your machine when being installed.
The DevKit is a handy toolchain that supplies everything you need for this to be done, automatically without you needed to do anything more than type gem install XXXXX. Without it, you either cannot use C extension gems, or must have already installed MSYS and MingW, have them configured properly, which is all not a user-friendly experience, even for those who familiar with the process.
So even if DevKit is optional, it is still required to make the most of Ruby on Windows.
Solution re-install ruby with rubyinstaller-devkit-2.5.5-1-x64
and issue
gem install bundler
gem install jekyll
I got the same error message. It turned out that the culprit was the ffi gem. I got it to work using this solution.
I had the same issue. I was able to resolve it (in Windows 11 x64) via:
winget install -e --id RubyInstallerTeam.RubyWithDevKit
(I.e., reinstall Ruby with the DevKit)

Getting an error when installing 'sudo gem install mechanize'

Even I have installed ruby-dev and ruby-make but still giving same error ? how to fix the error ?
sudo gem install mechanize
Building native extensions. This could take a while...
ERROR: Error installing mechanize:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/bin/ruby2.4 -r ./siteconf20180417-8728-15wdd1s.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/unf_ext-0.0.7.5/gem_make.out
You don't have the source code for Ruby so when it attempts to compile the gem it fails. It's looking for /usr/lib/ruby/include/ruby.h but that file isn't present on your system.
Generally, it's not a good idea to use the system version of Ruby. (for this reason, and others) You should use a Ruby manager to install Ruby into your user profile, as this will make compiling gems a lot easier.
For example, you can use RVM to install Ruby:
\curl -sSL https://get.rvm.io | bash -s stable
This will install the latest version of rvm, which you can then use to install Ruby 2.4:
rvm install 2.4
You can install nearly any version of Ruby by specifying its version, for example Ruby 2.5:
rvm install 2.5
Afterwards, running ruby will automatically run the version installed by RVM. And since it's installed in your profile, you don't need to use sudo for any operations. (and you should never use sudo when using rvm or Rubies installed by rvm)
In your case, you would then be able to run gem install mechanize successfully because it would be using the Ruby installation in your home directory that includes a copy of the source code and header files.
If for some reason you can't use RVM or don't want to use RVM, then you need to have the Ruby header files installed. The way to install these headers varies by operating system so there's no one answer I can give you. If your OS is a Debian-based version of Linux, for example, you can install the headers with:
sudo apt-get install ruby2.4-dev
More information is available in another answer on stackoverflow.

Why need DevKit

When I tried to setup my debug environment for Ruby.
I have to get gem package debug_base and debug_ide from repository. 'gem install xxx' command will download packages and using DevKit to compile the package. I was thinking why weren't these gem package compiled in advance? So we don't need DevKit to do build job when installing them. Is there any other purpose for DevKit?
Some packages/gems need to be compiled in advance to work because they use native extensions.
This is done automatically by ruby gem when you use the gem command.
Devkit is:
The RubyInstaller Development Kit is a toolkit that makes it easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows

NetBeans 6.9.1 and the ruby FastDebugger

I need to use ruby 1.8.6 to run a legacy script. I've installed NetBeans 6.9.1 and I'm trying to use the fast debugger but when I try to install it I get:
/home/eianni/.rvm/gems/ruby-1.8.6-p420#xml2rpc/gems/rubygems-bundler-0.3.0/lib/rubygems_bundler/regenerate_binstubs_command.rb:34: warning: parenthesize argument(s) for future version
Building native extensions. This could take a while...
ERROR: Error installing ruby-debug-ide:
ERROR: Failed to build gem native extension.
/home/eianni/.rvm/rubies/ruby-1.8.6-p420/bin/ruby mkrf_conf.rb
/home/eianni/.rvm/gems/ruby-1.8.6-p420#xml2rpc/gems/rubygems-bundler-0.3.0/lib/rubygems_bundler/regenerate_binstubs_command.rb:34: warning: parenthesize argument(s) for future version
Gem files will remain installed in /home/eianni/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.9 for inspection.
Results logged to /home/eianni/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/gems/1.8/gems/ruby-debug-ide-0.4.9/ext/gem_make.out
This is probably because the ruby version is too old, but is there a way to tell Netbeans to use a different version for ruby-debug-ide. I can install withouth problems ruby-debug-ide 0.10.0.
I'm using Ubuntu 10.04
In order to use ruby-debug-ide 0.4.9 with Ruby 1.8.6, you have to install ruby-debug-base 0.10.3 and linecache 0.45.
To know and manage your gems in Netbeans :
Tools -> Ruby Gems -> Installed

Ruby: Cannot Install Watir Gem On Windows

Watir's site says I need Ruby 1.8.6, which I'm running. And windows installation should be as simple as gem install watir. But when I run that, I get this:
C:\Users\Ryguy\Code>gem install watir
Building native extensions. This could take a while...
ERROR: Error installing watir:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb
checking for strncpy_s()... no
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/win32-api-1.4.5 f
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/win32-api-1.4.5/ext/gem_make.out
My Ruby Version: ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]
My RubyGems Version: 1.3.5
I would recommend you install the RubyInstaller Development Kit as documented here
Once you've installed it, the compile process of Watir dependencies (win32-api) will install successfully.
Turns out I needed to install the Ruby Development files. =/
Execute Below command and its works
gem install watir --platform=mswin32
Installed devkit and after calling the bat file on Windows 7 from a cmd it fixed this issue. Using Ruby 1.9.1
I also had to install nokogiri to get Watir to install successfully on windows, after installing DevKit. Use: gem install nokogiri

Resources