I was trying to install Rails on my mac by using the command:
sudo gem install rails
But it threw me the following error
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
This happens if I haven’t installed the Xcode Command Line Tools properly. To do that
Run xcode-select –install in terminal
This would install the Xcode command line tools. Thats it, you are good to go.
Re run the sudo gem install rails in the terminal and it will install the rails.
To verify if the rails is installed properly. Run rails -v in terminal.
This shows us the version of the rails installed on the machine.