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.
Related
I am trying to install fat free crm on a Windows 10 machine, but so far I have been unsuccessful. This is my latest attempt. Any help will be greatly appreciated.
Running bundler install gives me these messages:
Bundler 2.3.7 is running, but your lockfile was generated with 2.3.10. Installing Bundler 2.3.10 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.10
Installing bundler 2.3.10
Fetching gem metadata from https://rubygems.org/.........
Lots of successfully installed gems later:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r
./siteconf20221119-16700-fgt0qd.rb extconf.rb
creating Makefile
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node/builder.rb:12:in
`build_libv8!': failed to download node 16.10.0 (Libv8::Node::BuilderError)
from
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node/location.rb:30:in
`install!'
from extconf.rb:9:in `<main>'
==== in
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/ext/libv8-node
==== running
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/libv8-node-16.10.0.0/libexec/download-node
extconf failed, exit code 1
My node version is v18.12.1, by the way. (Do I need an older one?)
Anyway, here is the exact sequence of actions before running bundler install inside my local git clone of fat_free_crm:
First, the repository I am using:
https://github.com/fatfreecrm/fat_free_crm
My Ruby version:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x64-mingw-ucrt]
For a fresh start, I uninstall all gems, including rails:
gem uninstall -aIx
The latest commit on the bin folder says: Upgrade to Rails 6 so I install the latest rails 6 version on my machine:
gem install rails -v 6.1.7
I clone the repository from github:
git clone https://github.com/fatfreecrm/fat_free_crm.git
Since I am using sqlite3 for this, I comment out all other db gems in the Gemfile and only leave this one:
gem 'sqlite3', '~> 1.4.0'
Then, I copy database.sqlite.yml into database.yml.
Then, I run bundler install from within the directory fat_free_crm, which gives me this:
Ensure you have either installed the shared-mime-info package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file.
I (hopefully) solved that problem with this stackoverflow solution: Error installing ruby on rails on windows 10
Afterwards, I run bundler install again, which gives the error messages that I mentioned at the top of my description.
Any help will be greatly appreciated.
P.S.: I am trying to get back into Ruby on Rails after a long break, so please forgive me, if I made any stupid mistakes.
I've installed Ruby sucessfully in my machine. After I install rails, I do a bundle install command. I have some problems when installation reaches kgio. It complains to RubyDevKit installation.
Gem::InstallError: The 'kgio' 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 kgio (2.10.0), and Bundler cannot
continue.
Make sure that `gem install kgio -v '2.10.0'` succeeds before bundling.
After the installation I run `bundle update` and get conflicting types
error.
This is the result of the mkmf.log file.
conftest.c:17:13: error: conflicting types for 'clock_gettime'
In file included from c:\rubydevkit\mingw\bin\../lib/gcc/x86_64-w64-
mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/time.h:285:0,
from c:\rubydevkit\mingw\bin\../lib/gcc/x86_64-w64-
mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/iptypes.h:13,
from c:\rubydevkit\mingw\bin\../lib/gcc/x86_64-w64-
mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/iphlpapi.h:15,
from C:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:44,
from C:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from C:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from C:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from conftest.c:1:
I understood this is a conflicting types issue. The problem is when I install RubyDevKit and after that I do a bundle update.
If those things are interlaced and they produce those problems, how can I solve this?
My Ruby version: 2.3.1
RubyDevKit: mingw64-64-4.7.2
Rails: 4.6.2
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 was able to install the rmagick-2.6.0-x86-mswin32.gem gem in my windows 7 machine using gem install command and I got the following success messages:
D:\dev>gem install rmagick-2.6.0
Successfully installed rmagick-2.6.0-x86-mswin32
1 gem installed
Installing ri documentation for rmagick-2.6.0-x86-mswin32...
Installing RDoc documentation for rmagick-2.6.0-x86-mswin32...
But when I try to install using bundle install (with the same version mentioned in the Gemfile) it throws the following error messages:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
. D:/Ruby187/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.2... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.6.0. Can't find Magick-config in D:\Ruby187\bin;D:\Ruby1
....
I already have ImageMagick installed and its paths included in the env vars, but the paths mentioned in the error message above seem to be different somehow(?!)
When i type rails -v now, I get the following message:
D:\dev>rails -v
←[31mCould not find gem 'rmagick (= 2.6.0) x86-mingw32' in the gems available on
this machine.←[0m
←[33mRun `bundle install` to install missing gems.←[0m
Do i need to make any other changes/ setups to install this gem with my gemfile using bundle install?
Also I actually need an earlier gem '2.5.2' but the win32 specific version of that gem does not seem to available, is there any way to get it?
I need to do this development on windows for the moment so I can switch to any other OS for the moment. Also since this is a legacy app I am working on, I will need to stick with rmagick and can't switch to any other solution.
Env info:
Ruby: 1.8.7
Rails:
Please help!
Many thanks.
Hey have you tried installing Devkit, for installing gems with native extensions on windows.
Try the steps in the following link, and check whether the Devkit has been installed in your path variable, try opening a new command shell and install the gems.
http://doelsengupta.blogspot.in/2010/10/unable-to-download-gem-with-native.html
all the best!!
I kept having this problem but was finally able to get around it using the following solution from #Martin Cohen - after modifying the gemspec file as he has suggested and rebuilding it, i was able to successfully install rmagick gem using bundle install...
https://stackoverflow.com/a/5595274/1865578
cheers!
I'm trying to use Rails, when I do this system says the following
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
Then I run - sudo gem install rails
and as the result I got
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/json-1.6.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/json-1.6.5/ext/json/ext/parser/gem_make.out
Any ideas how to solve this?
You're a Mac user. The 'common build tools', known as the 'BSD subsytem' in the Xcode package are often outdated. For example the installed ruby is at version 1.8. Do yourself a huge favor and install the common build tools via homebrew package manager. After that I suggest installing a newer version of ruby as rails will soon drop support for the 1.8 series that you're using. Different version of ruby are installed using the ruby version manager
After installing homebrew and rvm you have rock solid base! Installing a ruby version is now just a matter of running rvm install 1.9.2 and you'll get the latest patch version of the 1.9.2 series of the MRI.
With ruby 1.9.2 you will have no problem installing the current version of RubyOnRails.
This chain if tools is what most Ruby/Rails devs use today.
he got problems with installing the json gem. I resolved that issue by installing the Ruby DevKit.
Download form here:
http://rubyinstaller.org/downloads/
Install tutorial here:
https://github.com/oneclick/rubyinstaller/wiki/Development-kit
Cheers Stefan