Rails on windows - install issue - ruby-on-rails

I'm trying to install ruby on a Windows box and am having an issue. I have gotten up to this point when I start getting errors, and I'm completely new to anything other than PHP for web development. Help appreciated!
EDIT I'm following the instructions here for wamp:
http://www.alexbernard.fr/fichiers/blog/Installer-Ruby-On-Rails-sur-un-Wamp-Server.pdf
./gem install rails --include-dependencies
Output:
INFO: `gem install -y` is now default and will be removed
INFO: use --ignore-dependencies to install only the gems you list
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:/wamp/ruby/bin/ruby.exe extconf.rb
creating Makefile
make
generating generator-x64-mingw32.def
compiling generator.c
make: x86_64-w64-mingw32-gcc: Command not found
make: *** [generator.o] Error 127
Gem files will remain installed in C:/wamp/ruby/lib/ruby/gems/2.0.0/gems/json-1.8.0 for inspection.
Results logged to C:/wamp/ruby/lib/ruby/gems/2.0.0/gems/json-1.8.0/ext/json/ext/generator/gem_make.out

From the output shown above, I assume the following:
Installed Ruby 2.0.0 x64 (64bits)
Installed some DevKit from RubyInstaller page
Now, as explained here, for 64bits Ruby you need 64bits DevKit.
From the error in the output:
make: x86_64-w64-mingw32-gcc: Command not found
It is clear you didn't install the right DevKit.
Please remove the DevKit installed, download the correct one (as indicated in the link above and in RubyInstaller downloads page) and install again.
You will require to use ruby dk.rb install --force (note the --force option) to override the previous DevKit installation.
As for the the deprecation error, --include-dependencies is no longer required. I recommend you use as installation reference a modern Ruby/Rails guide.

You can go the RailsInstaller way to install Rails and all dependencies in one go without getting into such problems.

For me, the problem was that the DevKit binaries did not get added to the PATH. Make sure that (DEVKIT_FOLDER)\mingw\bin is on the path.

Because I read this answer with hope of fixing my problem, and found it did not help, here's how I resolved it:
--
Your error is:
make: x86_64-w64-mingw32-gcc: Command not found
--
The error means that you don't have access to the gcc/gc++ compiler on your PC.
You should therefore either locate, or download a version of the compiler to your system. I found installing the build tools located here solved the issue.
You just have to download those tools, then add them to the PATH var: set PATH=C:/path/to/your/ming64/location/;%PATH%;
This should build it for you.
A caveat -- whether you have the correct dependencies for a build to take place is another question entirely.

The exe is in rubydevkit\mingw\bin. Just add that to your path and json will build.

Related

ERROR: Failed to build gem native extension Windows 7 32 Bit

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

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

gem install jekyll error on windows

I have created new twitter-bootstrap project on Webstorm 7 and updated npm then executed the grunt comment I got the below error in Jekyll
Running "jekyll:docs" (jekyll) task Warning:
Please install Jekyll before running this task. Use --force to continue.
Aborted due to warnings.
Then I followed the steps as given by (http://www.madhur.co.in/blog/2011/09/01/runningjekyllwindows.html) URL now I am getting error on
gem install jekyll
step. Please look at the below error log on gem_make.out file
C:/Ruby200/bin/ruby.exe extconf.rb creating Makefile
make "DESTDIR=" generating stemmer-i386-mingw32.def compiling porter.c
make: execvp: gcc: Bad file number make: * [porter.o] Error 127
Please guide me how to come over this issue.
Here is a guide on How to Run Jekyll on Windows.
It covers installing the Ruby DevKit, which is most likely what you're missing.
Alternately, and assuming you're on Windows, you could install Ruby using scoop, it's very simple to use and it will install the DevKit along with Ruby.
I hope this helps.

"Failed to build gem native extension" when installing Rails

I'm new to Terminal so please bear with me. Completed installing the following successfully (in this particular order):
xCode 4.5
RVM 1.16
GCC 4.2.1
Ruby 1.9.3
When trying to install Rails ("gem install rails") the installation starts but is then interrupted with an error: "Failed to build gem native extension". No idea what this refers to. Ideas? Something else I need to install beforehand?
On my first attempt to install Rails I accidentally ran it with sudo. Will this affect anything?
Edit: And the output -
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/Users/staffanestberg/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
Gem files will remain installed in /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5 for inspection.
Results logged to /Users/staffanestberg/.rvm/gems/ruby-1.9.3-p194/gems/json-1.7.5/ext/json/ext/generator/gem_make.out
Edit: Solved using iouri's suggestion. Add export CC=gcc in .bash-profile then create a symlink for the correct compiler,
sudo ln -sf /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2
Make sure you have command line tools for Xcode installed first, Xcode > Preferences > Downloads > Components. Then add this line to your .bash_profile file in your home folder ~/.bash_profile:
export CC=gcc
Double check that you have gcc (probably a symlink) in your /usr/bin (most likely), and that it is pointing to a valid gcc compiler, ex: gcc -> llvm-gcc-4.2
You might have to restart your terminal for this change to take affect.
Ruby is not fully ready for LLVM compilation, this includes clang, there is at least one known isue with Fibers, but depending on LLVM version other problems might appear.
The right way to fix it is to get gcc-4.2 there are many ways for it and the best ones are described in requirements:
rvm get stable
rvm reload
rvm requirements run
rvm reinstall 1.9.3

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