I'm trying to install a rails app on Windows. When I invoke this command:
bundle install
I get this error:
How to fix it?
You need to install a Ruby Development Kit as described here: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
It will install a mingw environment allowing rubygems to compile binary gems for the Windows platform.
Be careful to follow the post-installation steps described in this section: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit#4-run-installation-scripts
Simply having the ruby-devkit files on your hard-drive is not enough for rubygems to make use of it.
The bundle install commands are included with the Ruby DevKit.
Make sure that if you've correctly installed the Ruby Dev Kit (https://rubyinstaller.org/add-ons/devkit/) it can also find where Ruby is installed on your HD.
When you use the command ruby dk.rb init you should get a message like this
[INFO] found RubyInstaller v2.3.3 at C:/Ruby23-x64
You can also use the ruby dk.rb review command to ensure that the DevKit has found your install path for Ruby. You should get a message like this
Based upon the settings in the 'config.yml' file generated
from running 'ruby dk.rb init' and any of your customizations,
DevKit functionality will be injected into the following Rubies
when you run 'ruby dk.rb install'.
C:/Ruby23-x64
Once you're happy with the directories specified in the config file, run the ruby dk.rb install command. If you're reinstalling the DevKit, you can use the -f command to overwrite anything done previously.
You should see something like this (if you used the -f):
[WARN] Updating (with backup) existing gem override for 'C:/Ruby23-x64'
[WARN] Updating (with backup) DevKit helper library for 'C:/Ruby23-x64'
Once that's done, you can check to see that your Devkit has installed properly by running the install json --platform=ruby command, after which you should see:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
Successfully installed json-2.1.0
Parsing documentation for json-2.1.0
Installing ri documentation for json-2.1.0
Done installing documentation for json after 2 seconds
1 gem installed
Once your json install starts, you know your DevKit has installed successfully, which should prevent the 'make' error from occurring.
Related
I am trying to install json ruby gem on Windows 7 32 System.
The local environment details are
D:\Environment\DevKit32Ruby200>gem -v
2.0.14
D:\Environment\DevKit32Ruby200>ruby -v
ruby 2.0.0p451 (2014-02-24) [i386-mingw32]
D:\Environment\DevKit32Ruby200>rails -v
Rails 4.0.4
I have already tried following things
Downgrading system ruby gems version to 2.3.0 using
gem update --system 2.3.0
I have done proper setting of devkit and manually I added proper ruby directory path in config.yml file.
D:\Environment\DevKit32Ruby200>ruby dk.rb init
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all
of the installed Rubies you want enhanced by the DevKit.
D:\Environment\DevKit32Ruby200>ruby dk.rb install --force
[WARN] Updating (with backup) existing gem override for 'D:/Environment/ruby200new'
[WARN] Updating (with backup) DevKit helper library for 'D:/Environment/ruby200new'
I have also tried putting platform=ruby
gem install json --platform=ruby --verbose
The error I am getting while installing json is bellow.
D:\Environment\DevKit32Ruby200>gem install json
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
D:/Environment/ruby200new/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR="
generating generator-i386-mingw32.def
compiling generator.c
linking shared-object json/ext/generator.so
make "DESTDIR=" install
/usr/bin/install -c -m 0755 generator.so ./.gem.20170109-8336-qvgvzc/json/ext
make: execvp: /usr/bin/install: Permission denied
make: *** [install-so] Error 127
Gem files will remain installed in D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2 for inspection.
Results logged to D:/Environment/ruby200new/lib/ruby/gems/2.0.0/gems/json-2.0.2/ext/json/ext/generator/gem_make.out
There are 10's of questions are already tagged on this issue but none resolved.
Kindly help me to identify whats missing and why the error coming.
i386-mingw32 is a mountain of pain that'll never be fully supported, when I spent time on Windows I used to use a VirtualBox VM with ubuntu installed which shares a folder with the Windows host. I would edit the files with netbeans in windows and run the code in putty, the VM would basically be headless.
I actually did a lot of real work that way. If you want to do a "Hello World" rails app - OK - good luck even with that. How about an online development environment such as https://c9.io/ ?
But if you want to work, not just play around, set yourself up with an Ubuntu VM at the very least, or work in Ubuntu/MacOS at the very best.
Try this out:
Why don't you download the json .gem file from rubygems.org and install it directly using command
gem install json-x.x.x.gem
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.
I am newbie to ruby on rails, here i am trying to install ruby on rails on windows 7 64 bit. i installed the ruby installer and i installed rails. and also i created new app files. but when i start the rails server it is showing the following errors.
How can i get rid of these errors and start developing my ruby application?
C:\Users\walnut\Desktop > bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.................
Using rake 10.4.2
Using i18n 0.7.0
Installing json 1.8.3 with native extensions
Gem::InstallError: The 'json' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
C:\Users\walnut\Desktop > rails s
Could not find gem 'mysql2 (>= 0) x64-mingw32' in any of the gem sources listed
in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
C:\Users\walnut\Desktop > gem install mysql2
Fetching: mysql2-0.3.19.gem (100%)
ERROR: Error installing mysql2:
The 'mysql2' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
C:\Users\walnut\Desktop > rails s
Could not find gem 'mysql2 (>= 0) x64-mingw32' in any of the gem sources listed
in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.
From here,
Follow the Instructions from the Ruby Installer Developer Kit Wiki:
Download DevKit file from rubyinstaller.org
Extract DevKit to path C:\RubyXXX\DevKit
Run cd C:\RubyXXX\DevKit
Run ruby dk.rb init
Run ruby dk.rb review
Run ruby dk.rb install
Where did you create your application? If you look at your command line, you are in your Desktop. You need to switch directories to your project folder to be in the right context.
Additionally, you need to install build tools to install json native extensions.
Please refer to/follow instructions from this other stack overflow answer - The 'json' native gem requires installed build tools.
As the error suggest you have to update your PATH to include build tools also known as DevKit.
If you have used RailsInstaller to install ruby on rails on your computer then it has already included in your rails installation directory. All you have to do now is to update your PATH to include it. See step 4 of instruction in DevKit Overview on Github.
If not follow above instruction to install DevKit and then get to work.
Try follow this step and one more thing, if you use x64 of ruby installer, then please use x64 devkit. Same applied to x86. I'm facing this issues and the link gave it(step to install) to you save my time. Hope this helped.
p/s : if i'm correct in windows, ruby v2.2 above was't support higher nokogiri, to get things working properly use either ruby v1.9.3 or v2.1.6.
Check this link also for nokogiri supported.
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.
I want to learn Ruby and i found an warning message in console while installation.
I have installed Ruby 2.0.0-p481 (x64) and extracted the DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe successfully.
Then i executed following command:
chdir C:\DevKit
ruby dk.rb init
ruby dk.rb install
Then i noticed the following in my console:
C:\Users\parthap>chdir C:\DevKit
C:\DevKit>ruby dk.rb init
Initialization complete! Please review and modify the auto-generated
'config.yml' file to ensure it contains the root directories to all of
the installed Rubies you want enhanced by the DevKit.
C:\DevKit>ruby dk.rb install
Invalid configuration or no Rubies listed. Please fix 'config.yml' and
rerun 'ruby dk.rb install
I am not getting any config.yml file.I can see a config.h file.
and what should be fixed there?
Thanks
Able to install ruby 1.9.3
previously was trying with Ruby 2.0.0
Ruby 2.0.0, specially the 64bits version, are relatively new on the Windows area and not all the packages have been updated to be compatible with it. To use this version you will require some knowledge about compilers and solving dependency issues, which might be too complicated if you just want to play with the language.
Thanks