Error when installing Ruby on Rails: Failed to build gem native extension
Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command
gem update --system 2.0.3
ruby install rails with Error ---Failed to build gem native extension.(Windows platform)
Just back from a vacation, and this problem has been solved during the holiday. Forgive me for not remembering to close this issue until now.XD
With the help of Josien's comments, the problem has narrowed down to gem install websocket-driver
failed. It's easier to find this problem on stackoverflow-Error when trying to install gem websocket-driver-0.7.3
Finally, I solved this problem just by typing ridk install
(to make MSYS2 work for ruby3.0.1)——I have installed MSYS2 and make it work under ruby2.7.4, but if you want to make it work for ruby3.0.1 samely , you need to excute this command under ruby3.0.1.
After installed MSYS2 for ruby3.0.1, rails installed sucessfully.
C:\Users\Administrator>Uru ls
274p191 : ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32]
310p0 : ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ruby -v
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x64-mingw-ucrt]
C:\Users\Administrator>ridk install
_____ _ _____ _ _ _ ___
| __ \ | | |_ _| | | | | | |__ \
| |__) | _| |__ _ _ | | _ __ ___| |_ __ _| | | ___ _ __ ) |
| _ / | | | '_ \| | | | | | | '_ \/ __| __/ _` | | |/ _ \ '__/ /
| | \ \ |_| | |_) | |_| |_| |_| | | \__ \ || (_| | | | __/ | / /_
|_| \_\__,_|_.__/ \__, |_____|_| |_|___/\__\__,_|_|_|\___|_||____|
__/ | _
|___/ _|_ _ __ | | o __ _| _ _
| (_) | |^| | | |(_|(_)\^/_>
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER [1,3] 1,3
> sh -lc true
MSYS2 seems to be properly installed
Install MSYS2 and MINGW development toolchain ...
> pacman -S --needed --noconfirm autoconf autogen automake-wrapper diffutils file
...
...
...
Install MSYS2 and MINGW development toolchain succeeded
1 - MSYS2 base installation
2 - MSYS2 system update (optional)
3 - MSYS2 and MINGW development toolchain
Which components shall be installed? If unsure press ENTER []
C:\Users\Administrator>gem install rails
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.8
Successfully installed actioncable-7.0.2
Successfully installed rails-7.0.2
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for nio4r-2.5.8
Installing ri documentation for nio4r-2.5.8
Parsing documentation for actioncable-7.0.2
Installing ri documentation for actioncable-7.0.2
Parsing documentation for rails-7.0.2
Installing ri documentation for rails-7.0.2
Done installing documentation for websocket-driver, nio4r, actioncable, rails after 2 seconds
4 gems installed
C:\Users\Administrator>rails -v
Rails 7.0.2
ERROR: Failed to build gem native extension on Windows
Finally after much research I found the culprit was the RubyGems version incompatibility with native extension gems!!!
I had ruby gems ver 2.4.1 but seems like >2.4.0 has these issues
gem update --system 2.3.0
did the trick for me :)
Refer: https://github.com/rubygems/rubygems/issues/977
Failed to install when creating project in rails because of sqlite3 in windows
Finally I give up, with sqlite3 it is impossible to make it work, it s one after another error.
The final solution after a dozen errors is to create the project with postgresql, install postgresql in Windows, and then create the project, and configure the database.yml file.
Receive: ERROR: Failed to build gem native extension when trying to install rails gem on ruby 1.9.2 using pik
The relevant part of the error message is gcc: Command not found
; so the compiler is not available to compile the code locally.
If you already have gcc
installed on your machine somewhere, make sure it is included in the PATH
.
Check the How to install gcc on windows 7 machine? for guidance on how to install gcc on windows.
Related Topics
Ruby Indented Multiline Strings
Using Bsearch to Find Index for Inserting New Element into Sorted Array
How to Fix an Accidental 'Sudo Bundle Install Dir_Name'
Rmagick - How to Find Out the Pixel Dimension of an Image
What Does +@ Mean as a Method in Ruby
How to Write an Rspec Test for a Ruby Method That Contains "Gets.Chomp"
How to Correctly Install Rvm in Docker
Make Rails Ignore Daylight Saving Time When Displaying a Date
How to Specify the Location of the Chromedriver Binary
How to Convert Ppt to Images in Ruby
If(!X) VS If(X==False) in Ruby
How to Convert Boolean Values to Integers
Rails ( Set_No_Cache Method) Cannot Disable Browser Caching in Safari and Opera
How to Give a Sub-Module the Same Name as a Top-Level Class
How to Redefine Fixnum's + (Plus) Method in Ruby and Keep Original + Functionality