Failed to build gem native extension? - ruby-on-rails

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.

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!

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)

errors when installing rails

I just downloaded ruby 2.6.5 and as well as sqlite3. I followed the tutorial to install rails and typed "gem install rails" in the command prompt but ran into this error. I have no idea what these things are and have been stuck here for quite a long time. Could someone give me some advice on this please? Any help will be greatly appreciated!
C:\>gem install rails
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:/ruby files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/websocket-driver-0.7.1/ext/websocket-driver
D:/ruby\ files/Ruby26-x64/bin/ruby.exe -I D:/ruby\ files/Ruby26-x64/lib/ruby/2.6.0 -r ./siteconf20191228-14032-rudo55.rb extconf.rb
creating Makefile
current directory: D:/ruby files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/websocket-driver-0.7.1/ext/websocket-driver
make "DESTDIR=" clean
Makefile:269: *** multiple target patterns. Stop.
current directory: D:/ruby files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/websocket-driver-0.7.1/ext/websocket-driver
make "DESTDIR="
Makefile:269: *** multiple target patterns. Stop.
make failed, exit code 2
Gem files will remain installed in D:/ruby files/Ruby26-x64/lib/ruby/gems/2.6.0/gems/websocket-driver-0.7.1 for inspection.
Results logged to D:/ruby files/Ruby26-x64/lib/ruby/gems/2.6.0/extensions/x64-mingw32/2.6.0/websocket-driver-0.7.1/gem_make.out

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.

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

Resources