gem install fileutils error - ruby-on-rails

Now I'm trying to open SVG file to get the data from it by Ruby language
using Rails 4.0.2
first I installed the " nokogiri " by using this command [ gem install nokogiri ] because I'm using Windows 7
then when I'm trying to install " fileutils " by using this command [gem install fileutils ]
But always I get this error
Blockquote
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
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.
Why i got this error ??

Seems like you need to install imagemagick first. You can download it from the official project page:
http://www.imagemagick.org
This should do it for you. Generally I suggest you to not to use Windows to develop. Ruby and Rails arent performing well on Windows and you can totally forget running a rails app on a windows host in production mode.
// you cant install imagemagick using the command gem install rmagick because rmagick is a wrapper for imagemagick but doesnt include the binary files. You need to install imagemagick first. To do that go to the website I posted => Binary Releases => Windows => Download ImageMagick-6.8.8-2-Q16-x64-dll.exe and install it. Then run bundle install again.
Also it can be a problem using windows when the rmagick gem isnt made for windows operating systems. Again: I strongly suggest you tu use a Linux Operating system for everything that is related to ruby, rails or programming web stuff.

Related

ERROR: Error installing rmagick: in Windows with Ruby 2.2

I cloned my code from git to my Windows machine and when I run bundle install, I am getting this error:
An error occurred while installing rmagick (2.13.4), and Bundler
cannot continue. Make sure that gem install rmagick -v '2.13.4'
succeeds before bundling.
D:\project\MyProject2>gem install rmagick -v '2.13.4'
Temporarily enhancing PATH to include DevKit... Building native
extensions. This could take a while... ERROR: Error installing
rmagick:
ERROR: Failed to build gem native extension.
D:/RailsInstaller/Ruby2.2.0/bin/ruby.exe -r ./siteconf20160721-7208-bn9t3e.rb extconf.rb checking for Ruby version
= 1.8.5... yes 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.
I tried downloading ImageMagick, and set environment paths as:
CPATH=D:\ImageMagick-6.9.5-Q8\include
LIBRARY_PATH=D:\ImageMagick-6.9.5-Q8\lib
and run bundle install but no use and also tried running
gem install rmagick -v '2.13.4' --platform=ruby -- --with-opt-lib=D:\ImageMagick-6.9.5-Q8\lib --with-opt-include=D:\ImageMagick-6.9.5-Q8\include
it is showing:
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.
Please help.
I had this same issue myself until I finally stumbled upon the answer on Stackoverflow here and here.
Basically you need to follow these steps:
Install DevKit. Since I used RailsInstaller to install Ruby on Rails on my laptop, it was already included in the default directory ‘C:\Serever\RailsInstaller\DevKit‘. Otherwise, find the .exe at the RubyInstallers downloads.
Install ImageMagick-6.9.5-9-Q16-x86-dll.exe from imagemagick.org. It seems that rmagik2.16 only supports ImageMagick 6, not ImageMagick 7.
Make sure that you install the correct version of ImageMagick x86 or x32. If you are unsure what ruby version you have install try this command: ruby -e "puts 1.size". It print 4 if x86 and 8 if x64. answer from here
Check the following options on the install screen (more info on the redmine website) :
[v] Add application directory to your system path
[v] Install development headers and libraries for C and C++
Setup in windows environment variables the PATH variable to include the path to ImageMagick. In my case: C:\Server\ImageMagick\. Make sure it is the first variable in the variables list, or you may encounter an “Invalid drive specification” error when extconf.rb tries to identify the ImageMagick version.
cd C:\YourRubyProject. Example: C:\Server\htdocs\dev-ruby\redmine.
Set CPATH and LIBRARY_PATH environment variables to point respectively to ImageMagick installation directory include and lib subdirectories (so the DevKit will find them at build time)
Open C:\Serever\RailsInstaller\DevKit\msys.bat. More details here
Run gem install rmagick --platform=ruby -- --with-opt-lib=C:/Server/ImageMagick/lib --with-opt-include=C:/Server/ImageMagick/include. Adjust paths as necessary for your project.
Finally, run bundle install, or if necessary bundle update
Note: for those that are looking to install redmine in xampp follow this tutorial. If you get stuck on installing the rmagick lib, return here to this answer and follow the provided steps.

Ruby on rails.. rails server command, strange output? [duplicate]

I'm running a clean install of Ruby 2.2.1 on Windows 8.1 with DevKit. After the installation I run:
gem install rails
rails new testapp
cd testapp
rails server
leaving everything else at default.
The process fails at the last line when, instead of running the server, I get the error message
in 'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError)
It happens every time and I've looked around and tried everything I found to fix it, but nothing so far has worked.
What is the problem here and how do I get a simple test Rails app to work?
Nokogiri doesn't support Ruby 2.2 on Windows yet. The next release will. See https://github.com/sparklemotion/nokogiri/issues/1256
Nokogiri doesn't support native builds (e.g. with devkit) on Windows. Instead it provides gems containing prebuilt DLLs.
There's a discussion which you may want to join or watch on the topic of devkit build support here: https://github.com/sparklemotion/nokogiri/issues/1190
First, uninstall the version of Nokogiri you currently have with:
gem uninstall nokogiri
Download Nokogiri 1.6.6.2 (x64) or Nokogiri 1.6.6.2 (x86)
Install this version locally using:
gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x64-mingw32.gem
or if you're running 32bit Ruby:
gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x86-mingw32.gem
The path may differ depending on where you downloaded the file to.
Try to start the server again using ruby bin\rails server, and it should work.
I got Nokogiri running with Ruby 2.2 on Windows 10 with a mix of Mike Dalessios and Julios answer:
Look for the latest version of Nokogiri in Nokogiri's github repo.
Run gem uninstall nokogiri.
Add gem "nokogiri", ">= 1.6.7.rc" to your Gemfile.
Run bundle install.
Run bundle update nokogiri if bundle has locked Nokogiri at some version.
Fix
Bundle install (gets Nokogiri files)
Browse to ruby_dir\lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2\ext\nokogiri
Open extconf.rb
Add dir_config('iconv').any? or pkg_config('libiconv') to #376
Download MinGW64 & MSYS folders from Mega
Add them to PATH in Windows (remove Devkit path refs - it doesn't work)
Download libxml2,libxslt, iconv libraries (or here)
Run ruby extconf.rb --platform=ruby --n --use-system-libraries referencing downloaded libraries
Run make
Run make install
Steps
Bundle Install
First step is to bundle.
This will put the nokogiri gem on your machine without running the pre-packaged compiler (which mostly doesn't work in Windows).
This will show Nokogiri as installed:
Browse
Browse to the nokogiri folder, to find ext/nokogiri/extconf.rb:
Open extconf.rb
... and add dir_config('iconv').any? or pkg_config('libiconv') to #376
Standard Nokogiri installs "rely" on the libxml2 inclusion of iconv - we need to explicitly define it, otherwise iconv.h is missing errors will occur.
Add Toolchain
Don't use devkit for this - it doesn't work.
You need MinGW:
I have zipped my exact MinGW64 and MSYS64 folders on Mega (key: !FJtcq25l-QMsNltCxllMhc1IGqORvap8xv8gWxSUbDA):
Add to PATH
This gives access to gcc & make (both required):
Remove the devkit ref from your path, and add the following:
MINGW64_PATH/bin
MSYS64_PATH/bin
Download Libs
I have added the libs to Mega:
You will unzip them here:
All the libs are from this source.
Run extconf.rb
Once libs are on your system, you can run ruby extconf.rb to configure the build:
32bit
ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/iconv-1.14-win32-x86 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxslt-1.1.28-win32-x86
64bit
#64
ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/iconv-1.14-win32-x86_64 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxslt-1.1.28-win32-x86_64
make
This may create errors / warnings, as long as it says "Error 1 (ignored)", it should be okay.
Following that, use make install:
Then browse to your Rails installation and run rails s:
Explanation
To give context:
Ruby 2.2+ on Windows doesn't compile the extensions Nokogiri requires.
The extensions of a gem are the extra dependencies (libraries) it uses.
They are built when you install the gem:
Extensions
Lack of extensions is preventing Nokogiri from running.
Extensions exist in the ext folder of a gem (you can read about them here):
Mysql2,RMagick,PGSQL, Nokogiri etc all use extensions/libraries.
This is why - on Windows - you have to use custom switches (--with-opt-dir) when installing the gem. This gives Ruby / the shell / (cmd) the required lib / include directories required to build the gem's files (it's the equivalent of how PATH works).
On Linux/Mac, these directories are managed with the respective package managers (brew/apt-get). Windows does not have this, so you have to install the extensions manually.
Because Windows does not have a standard set of libraries, you have to download them yourself. You also have to build them yourself (which is tricky).
The fix for Nokogiri install is to use the right libraries and build tools to get the gem installed.
Build
The difference with Ruby 2.2+ is the gem will "install" without showing any exceptions. You think it has installed, only to find Rails does not load (hence the nokogiri/nokogiri.so error).
This means you have to make sure you have the files on your system, and run the compiler to install them.
The above documentation should show you how to do that.

'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError) when running `rails server`

I'm running a clean install of Ruby 2.2.1 on Windows 8.1 with DevKit. After the installation I run:
gem install rails
rails new testapp
cd testapp
rails server
leaving everything else at default.
The process fails at the last line when, instead of running the server, I get the error message
in 'require': cannot load such file -- 'nokogiri\nokogiri' (LoadError)
It happens every time and I've looked around and tried everything I found to fix it, but nothing so far has worked.
What is the problem here and how do I get a simple test Rails app to work?
Nokogiri doesn't support Ruby 2.2 on Windows yet. The next release will. See https://github.com/sparklemotion/nokogiri/issues/1256
Nokogiri doesn't support native builds (e.g. with devkit) on Windows. Instead it provides gems containing prebuilt DLLs.
There's a discussion which you may want to join or watch on the topic of devkit build support here: https://github.com/sparklemotion/nokogiri/issues/1190
First, uninstall the version of Nokogiri you currently have with:
gem uninstall nokogiri
Download Nokogiri 1.6.6.2 (x64) or Nokogiri 1.6.6.2 (x86)
Install this version locally using:
gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x64-mingw32.gem
or if you're running 32bit Ruby:
gem install --local C:\Users\$user$\Downloads\nokogiri-1.6.6.2-x86-mingw32.gem
The path may differ depending on where you downloaded the file to.
Try to start the server again using ruby bin\rails server, and it should work.
I got Nokogiri running with Ruby 2.2 on Windows 10 with a mix of Mike Dalessios and Julios answer:
Look for the latest version of Nokogiri in Nokogiri's github repo.
Run gem uninstall nokogiri.
Add gem "nokogiri", ">= 1.6.7.rc" to your Gemfile.
Run bundle install.
Run bundle update nokogiri if bundle has locked Nokogiri at some version.
Fix
Bundle install (gets Nokogiri files)
Browse to ruby_dir\lib\ruby\gems\2.2.0\gems\nokogiri-1.6.6.2\ext\nokogiri
Open extconf.rb
Add dir_config('iconv').any? or pkg_config('libiconv') to #376
Download MinGW64 & MSYS folders from Mega
Add them to PATH in Windows (remove Devkit path refs - it doesn't work)
Download libxml2,libxslt, iconv libraries (or here)
Run ruby extconf.rb --platform=ruby --n --use-system-libraries referencing downloaded libraries
Run make
Run make install
Steps
Bundle Install
First step is to bundle.
This will put the nokogiri gem on your machine without running the pre-packaged compiler (which mostly doesn't work in Windows).
This will show Nokogiri as installed:
Browse
Browse to the nokogiri folder, to find ext/nokogiri/extconf.rb:
Open extconf.rb
... and add dir_config('iconv').any? or pkg_config('libiconv') to #376
Standard Nokogiri installs "rely" on the libxml2 inclusion of iconv - we need to explicitly define it, otherwise iconv.h is missing errors will occur.
Add Toolchain
Don't use devkit for this - it doesn't work.
You need MinGW:
I have zipped my exact MinGW64 and MSYS64 folders on Mega (key: !FJtcq25l-QMsNltCxllMhc1IGqORvap8xv8gWxSUbDA):
Add to PATH
This gives access to gcc & make (both required):
Remove the devkit ref from your path, and add the following:
MINGW64_PATH/bin
MSYS64_PATH/bin
Download Libs
I have added the libs to Mega:
You will unzip them here:
All the libs are from this source.
Run extconf.rb
Once libs are on your system, you can run ruby extconf.rb to configure the build:
32bit
ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxml2-2.9.2-win32-x86/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/iconv-1.14-win32-x86 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/32bit/libxslt-1.1.28-win32-x86
64bit
#64
ruby extconf.rb --platform=ruby -N -- --use-system-libraries --with-xml2-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64 --with-xml2-include=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxml2-2.9.2-win32-x86_64/include/libxml2 --with-iconv-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/iconv-1.14-win32-x86_64 --with-xslt-dir=C:/Dev/Dependencies/Ruby/lib/nokogiri/64bit/libxslt-1.1.28-win32-x86_64
make
This may create errors / warnings, as long as it says "Error 1 (ignored)", it should be okay.
Following that, use make install:
Then browse to your Rails installation and run rails s:
Explanation
To give context:
Ruby 2.2+ on Windows doesn't compile the extensions Nokogiri requires.
The extensions of a gem are the extra dependencies (libraries) it uses.
They are built when you install the gem:
Extensions
Lack of extensions is preventing Nokogiri from running.
Extensions exist in the ext folder of a gem (you can read about them here):
Mysql2,RMagick,PGSQL, Nokogiri etc all use extensions/libraries.
This is why - on Windows - you have to use custom switches (--with-opt-dir) when installing the gem. This gives Ruby / the shell / (cmd) the required lib / include directories required to build the gem's files (it's the equivalent of how PATH works).
On Linux/Mac, these directories are managed with the respective package managers (brew/apt-get). Windows does not have this, so you have to install the extensions manually.
Because Windows does not have a standard set of libraries, you have to download them yourself. You also have to build them yourself (which is tricky).
The fix for Nokogiri install is to use the right libraries and build tools to get the gem installed.
Build
The difference with Ruby 2.2+ is the gem will "install" without showing any exceptions. You think it has installed, only to find Rails does not load (hence the nokogiri/nokogiri.so error).
This means you have to make sure you have the files on your system, and run the compiler to install them.
The above documentation should show you how to do that.

Failed to build native gem extension sqlite3

I'm trying to install sqlite3-ruby on Cygwin with gem install sqlite3-ruby -v x.x.x and I get the following error:
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
checking for fdatasync() in -lrt... *** 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.
Does anyone know how to install sqlite3 for Ruby on Rails on Cygwin. As I understand it the SQLite RubyGem isn't actually a *Ruby*Gem, it's a "*C*Gem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it, so any help?
So this isn't a complete solution as I don't have a windows box and cygwin handy but the error message suggests that the linux utility fdatasync can't be found.
The tools linux man page can be found here
http://linux.die.net/man/2/fdatasync
Maybe find out if you have fdatasync installed correctly and try again.
I ran into this issue just now – the first time I wanted to install a Ruby gem
on my new Cygwin 64-bit system.
As I understand it the SQLite RubyGem isn't actually a RubyGem, it's a
"CGem", IOW it's written in C. This means it has to be compiled and linked
to the Ruby interpreter when you install it.
Cygwin actually provide a pre-compiled package which installs the sqlite3
gem files including the sqlite3_native.so linked library file. The name of
the package is ruby-sqlite3 and you can install it using Cygwin’s Setup.exe.
I personally like to use apt-cyg
when possible (not always) so I installed the package using:
apt-cyg install ruby-sqlite3
This package installs the appropriate gem files as can be seen by running
cygcheck -l ruby-sqlite3:
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/gem.build_complete
/usr/lib/gems/ruby/2.0.0/sqlite3-1.3.9/sqlite3/sqlite3_native.so
/usr/share/gems/gems/sqlite3-1.3.9/API_CHANGES.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/ChangeLog.cvs
/usr/share/gems/gems/sqlite3-1.3.9/CHANGELOG.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.rb
/usr/share/gems/gems/sqlite3-1.3.9/faq/faq.yml
/usr/share/gems/gems/sqlite3-1.3.9/Gemfile
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/constants.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/database.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/errors.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/pragmas.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/resultset.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/statement.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/translator.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/value.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3/version.rb
/usr/share/gems/gems/sqlite3-1.3.9/lib/sqlite3.rb
/usr/share/gems/gems/sqlite3-1.3.9/LICENSE
/usr/share/gems/gems/sqlite3-1.3.9/Manifest.txt
/usr/share/gems/gems/sqlite3-1.3.9/README.rdoc
/usr/share/gems/gems/sqlite3-1.3.9/tasks/faq.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/gem.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/native.rake
/usr/share/gems/gems/sqlite3-1.3.9/tasks/vendor_sqlite3

Cannot install JSON gem in rails using windows

I am doing a bundle install and all of the gems work fine except JSON when it get to the JSON gem I receive this error.
Installing json (1.6.1) with native extensions c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:55
2:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::E
xtensionBuildError)
c:/Ruby192/bin/ruby.exe extconf.rb
checking for re.h... *** 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.
Any idea on what could be causing this error?
You are working with Windows, so the RubyInstaller Development Kit may help you:
http://rubyinstaller.org/add-ons/devkit/
The devkit installs a C-compiler (and some other stuff) to compile C-written parts.
Install it and try again to install the gem - perhaps with option --platform=ruby.
Details can be found at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
That's because this gem using a piece of code written on C. For working properly you need c compiler installed on your machine. As a way, try to use json_pure written on pure Ruby
I'm not an expert in ROR, but the JSON installation issue which I got while installing Redmine was resolved by doing the following:
Create a make.bat at D:\LANGS\MinGW\bin
Keep this directory in the PATH
Edit the above make.bat and add a line, D:\LANGS\MinGW\msys\1.0\bin\make.exe
What I realized is, mingw32-make.exe never worked, but 'D:\LANGS\MinGW\msys\1.0\bin\make.exe' worked.
Note: My MinGW installation is under D:\LANGS\ . Please make the changes accordingly in your specific installation.
Yes, install the development kit. Also, You will need to run a few command lines to install it (not just simply download and run).
Download it, run it to extract it somewhere (permanent). Then cd to it, run ruby dk.rb init and ruby dk.rb install to bind it to ruby installations in your path.
A guide for that is here:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

Resources