Error in installing json gem for ruby in windows - ruby-on-rails

While I am trying to create the new rails project, I face to error that is related to the lack of json gem.
When I try to install json gem, this error happens:
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.
C:/Ruby22-x64/bin/ruby.exe extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
In file included from c:/Ruby22-x64/include/ruby-2.2.0/ruby/ruby.h:29:0,
from c:/Ruby22-x64/include/ruby-2.2.0/ruby.h:33,
from ../fbuffer/fbuffer.h:5,
from generator.c:1:
c:/Ruby22-x64/include/ruby-2.2.0/ruby/defines.h:26:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-1.8.3 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/json-1.8.3/gem_make.out

If you want to install Ruby 2 (or greater) on Windows 7 (64 bit), you need to install DevKit 64 bit as well. Your Devkit has to be compatible with your operating system.
So, make sure you installed the correct Ruby and the compatible Devkit on your system.
See this tutorial for more information.

There was a group of gems which are dependent together. So, I had to install step by step.
As I did it based on error messages and one by one, I forgot to make a note about the steps.

Related

gem install rails on git bash (for Windows)

gem install rails
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/site_ruby/3.1.0 -r ./siteconf20220326-12676-skaw7l.rb extconf.rb
creating Makefile
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR= clean
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR=
generating websocket_mask-x64-mingw-ucrt.def
compiling websocket_mask.c
make: gcc: No such file or directory
make: *** [Makefile:246: websocket_mask.o] Error 127
make failed, exit code 2
Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/websocket-driver-0.7.5 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/websocket-driver-0.7.5/gem_make.out
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Please help me to get rid of this error.
have you followed any Youtube tutorials if yes, then yeah you are not alone I have also screwed up and don't have any solutions yet but I think reinstalling from the beginning from your own not from the tutorials, you may succeed.
If I succeed then I would tell ya!

Ruby `json` gem does not compile

I am trying to get Rails working on a Windows system. I installed RubyInstaller and the Devkit, but I cannot seem to get the json gem to install. When I try gem install json I get:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-i386-mingw32.def
compiling generator.c
generator.c:1:0: error: CPU you selected does not support x86-64 instruction set
generator.c:1:0: error: CPU you selected does not support x86-64 instruction set
make: *** [generator.o] Error 1
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.3 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.3/ext/json/ext/generator/gem_make.out
It could be my Ruby versions (I have both 2.2 and 1.9), but I do not know. What is going on?
After #Azolo posted his comment, I discovered that the DevKit version I was using did not match the Ruby version I was running. The problem came to be because I needed Ruby 1.9.3 on the path for the Heroku client to function, but was trying to use 2.2 DevKit (as I typically use Ruby 2.2 for development.

Error installing rails 4 in mac

I am trying to set up rails in my mac(Yosemite) machine. But when I do
gem install rails
I get the following error. Please help.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/Paa/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling generator.c
make: /usr/local/opt/gcc46/bin/gcc-4.6: No such file or directory
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/Paa/.rvm/gems/ruby-1.9.3-p547/gems/json-1.8.2 for inspection.
Results logged to /Users/Paa/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/json-1.8.2/gem_make.out
What am I missing here.??
I think rvm might be trying to use gcc 4.6, which doesn't work properly with rvm. I believe you can:
Uninstall gcc 4.6 (brew rm gcc46)
Pull the latest rvm (rvm get stable)
Retry gem install rails

Error while typing "gem install rails"

Can anybody please help me to resolve this error.Actually i am trying to install ruby-1.9.3 and rails-4 in windows-XP 32 bit.When i followed the below steps and got some error.
Steps:
1-I installed ruby version-1.9.3
2-I installed the proper devkit and gave path(C:\Ruby193\devkit) to extract it.
3-I typed gem update --system in CMD.
4-When i typed the command gem install rails in cmd it gave some error.
Error:
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe -r ./siteconf20141229-2792-pk1no5.rb extconf.rb
creating Makefile
make clean
Makefile:165: *** target pattern contains no `%'. Stop.
make
Makefile:165: *** target pattern contains no `%'. Stop.
make failed, exit code 2
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.
1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/js
on-1.8.1/gem_make.out
Please help me to resolve this error.Thanks

how to install caldecott on win 7?

I have created an and I want to upload that on phpfog but I am getting trouble while uploading my database here on the first step, I have win 7 x64 , I downloaded and installed command prompt with ruby, while creating a tunnel :
C:\Ruby200\devkit>gem install caldecott --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing caldecott:
ERROR: Failed to build gem native extension.
C:/Ruby200/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-i386-mingw32.def
compiling generator.c
generator.c: In function 'cState_aref':
generator.c:632:5: warning: variable 'state' set but not used [-Wunused-but-set-
variable]
generator.c: In function 'isArrayOrObject':
generator.c:867:5: warning: suggest parentheses around '&&' within '||' [-Wparen
theses]
linking shared-object json/ext/generator.so
make install
/usr/bin/install -c -m 0755 generator.so C:/Ruby200/lib/ruby/gems/2.0.0/gems/jso
n-1.6.8/ext/json/ext/json/ext
/usr/bin/install: cannot create regular file `C:/Ruby200/lib/ruby/gems/2.0.0/gem
s/json-1.6.8/ext/json/ext/json/ext': No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.
8 for inspection.
Results logged to C:/Ruby200/lib/ruby/gems/2.0.0/gems/json-1.6.8/ext/json/ext/ge
nerator/gem_make.out
C:\Ruby200\devkit>gem install caldecott --platform=ruby
`
I have Win7 x64, Ruby 2.0.0, DevKit (DevKit-mingw64-32-4.7.2-20130224-1151)
I faced the same issue. My solution:
Download gem source from github - https://github.com/cloudfoundry/caldecott/archive/master.zip
Unzip to C:\caldecott (for example)
Open file caldecott.gemspec and change version of json dependency to "~> 1.7"
Open command prompt, move to gem source directory and perfrom:
gem build caldecott.gemspec
gem install caldecott-0.0.5.gem
That's all
This error occurs with Ruby 2.0.0 version. Downgrade to Ruby 1.9.3

Resources