gem install nio4r -v 2.0.0 fails on windows 10 - ruby-on-rails

I'm attempting to setup rails on windows 10 but I keep encountering an issue while attempting to install the nio4r gem.
C:\>gem install nio4r -v 2.0.0
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing nio4r:
ERROR: Failed to build gem native extension.
current directory:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
C:/RailsInstaller/Ruby2.3.0/bin/ruby.exe -r ./siteconf20170317-11700-9smes9.rb extconf.rb
checking for unistd.h... yes
checking for sys/select.h... no
checking for poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... no
checking for port.h... no
checking for sys/resource.h... no
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/nio4r-2.0.0/mkmf.log
current directory:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
C:\Program Files (x86)\GnuWin32\bin\ "DESTDIR=" clean
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
current directory:
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0/ext/nio4r
C:\Program Files (x86)\GnuWin32\bin\ "DESTDIR="
'C:\Program' is not recognized as an internal or external command,operable program or batch file.
make failed, exit code 1
Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nio4r-2.0.0 for inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/nio4r-2.0.0/gem_make.out
Initially, I attempted to avoid using the "railsinstaller" for windows but I ended up trying it thinking it may have a workaround for this unfortunately it did not and I still have the same issue.
Any ideas as to how I can fix this?

The developers seemingly have fixed this issue as everything went through for me the last time I tried this some
weeks ago!

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!

Failed to build gem native extension?

I have recently tried to install rails via gem by running gem install rails. However, it always fails with the following error message.
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
D:/Program\ Files/Ruby30-x64/bin/ruby.exe -I D:/Program\ Files/Ruby30-x64/lib/ruby/3.0.0 -r ./siteconf20210303-3696-skc9xl.rb extconf.rb
creating Makefile
current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make "DESTDIR=" clean
Makefile:269: *** multiple target patterns. Stop.
current directory: D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3/ext/websocket-driver
make "DESTDIR="
Makefile:269: *** multiple target patterns. Stop.
make failed, exit code 2
Gem files will remain installed in D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/gems/websocket-driver-0.7.3 for inspection.
Results logged to D:/Program Files/Ruby30-x64/lib/ruby/gems/3.0.0/extensions/x64-mingw32/3.0.0/websocket-driver-0.7.3/gem_make.out
Does anyone know what is actually happening here? I would appreciate any answer. Thanks
Usually, this "multiple target patterns" error when compile gem extensions is caused by spaces in directory names where you have installed your Ruby or your gems.
Especially on Windows, you should install your Ruby to a directory which contains no spaces, rather than your current location D:/Program Files/Ruby30-x64. To fix this, I recommend to uninstall Ruby and install it again to a more appropriate location.

Cannot installing Rails

I'm installing Rails on Windows. When I run gem install rails I received message
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/nio4r-2.5.2/ext/nio4r
C:/Ruby26-x64/bin/ruby.exe -I C:/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20200417-11800-rf5t47.rb
extconf.rb
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/nio4r-2.5.2/ext/nio4r
make "DESTDIR=" clean
current directory: C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/nio4r-2.5.2/ext/nio4r
make "DESTDIR="
make failedNo such file or directory - make "DESTDIR="
Gem files will remain installed in C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/nio4r-2.5.2 for inspection.
Results logged to C:/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/nio4r-
2.5.2/gem_make.out
I have no idea about that error. How to resolve that?
Old question, but might be still be relevant for people arriving through search. I installed the latest Ruby + devkit from https://rubyinstaller.org/downloads/, and it worked (Windows 10)

Error installing therubyracer on osx 10.12.4

I have gone through a lot of answers on a similar questions but I have not been successful. I am trying to install therubyracer 0.12.3 on my MAC OSX 10.12.4 and I am receiving the following error. Please help. Been stuck with this for two days now.
sudo gem install therubyracer -v '0.12.3'
Building native extensions.
This could take a while... ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
current directory: /Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
/Users/aj035785/.rvm/rubies/ruby-2.3.1/bin/ruby -r
./siteconf20170420-2619-13h8man.rb extconf.rb checking for main() in
-lpthread... yes checking for main() in -lobjc... yes creating Makefile
current directory:
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR=" clean
current directory:
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3/ext/v8
make "DESTDIR=" compiling accessor.cc make:
/usr/local/opt/apple-gcc42/bin/g++-4.2: No such file or directory
make: *** [accessor.o] Error 1
make failed, exit code 2
Gem files will remain installed in
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/therubyracer-0.12.3
for inspection. Results logged to
/Users/aj035785/.rvm/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-16/2.3.0/therubyracer-0.12.3/gem_make.out
Blockquote
I feel this might be the root cause -
make: /usr/local/opt/apple-gcc42/bin/g++-4.2: No such file or directory

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. - Yosemite

I am using Rails 4. Bundle was working up until yesterday, when I had to reinstall Bundler because of a different error. Now, when I run "bundle install", a few gems are successfully installed and then I receive this error message:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -r ./siteconf20150509-3462-k6ug3q.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
make: gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.0.0/gems/json- 1.8.2 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.0.0/extensions/x86_64-darwin- 10/2.0.0-static/json-1.8.2/gem_make.out
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
I then try to 'gem install json -v '1.8.2' and get this error message:
Building native extensions. This could take a while...
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/ext/builder.rb:73: warning:
Insecure world writable dir /usr/local/lib/ruby/gems/2.0.0 in PATH, mode 040777
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -r ./siteconf20150509-3898-12pmbxe.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
make: gcc-4.2: No such file or directory
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.0.0/gems/json-1.8.2 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.0.0/extensions/x86_64-darwin- 10/2.0.0-static/json-1.8.2/gem_make.out
I have no idea how to fix this. I have tried several solutions including:
-"rvm implode"
-"sudo gem update --system"
-"sudo gem update --system --no-user-install"
-"sudo chmod 755 /usr/local/lib/ruby/gems/2.0.0/gems"
-"xcode-select --install"
-running Disk Repair
I read a few things about making changes to the path and bash profile, but I am unclear on how to do that.
Thank you in advance! Already spent 2 hours trying to solve this.
Answered in this stack question : Insecure world writable dir /Users/username in PATH, mode 040777 when running Ruby commands
Your home folder should only be writable by you, not by anyone else. The reason gem is complaining about this is that you have folders in your PATH that are inside your (insecure) home folder, and that means that anyone who wants to could hack you by renaming/moving your .rvm folder and replacing it with an impostor.
To fix your home folder, run chmod go-w /Users/kristoffer. If there are any other insecure folders on the way to anything in your PATH, you should fix them similarly.
BTW, the reason that Disk Utility didn't repair this is that it only repairs files installed as part of the OS (see Apple's KB article on the subject). There is an option to repair home folder permissions if you boot from the install DVD and run Password Reset from the Utilities menu, but I'm not sure if it resets the permissions themselves or just ownership.
Update
Installing a new version of Ruby seemed to work. Previously I was using 2.0.0, and now I upgraded to 2.2.2. This seems to have made the issue go away.

Resources