I'm setting up servers. I'm installing rails on an Amazon Linux
Installed List: ruby, development tools, gems, zlib-devel, readline-devel.
I'm trying to install rails and now I'm stuck here
$ sudo gem install rails Building native extensions. This could take
a while... ERROR: Error installing rails: ERROR: Failed to build gem
native extension.
/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in
/usr/lib64/ruby/gems/1.8/gems/json-1.6.3 for inspection. Results
logged to
/usr/lib64/ruby/gems/1.8/gems/json-1.6.3/ext/json/ext/parser/gem_make.out
Is there a problem with this json library?
You need to install the following
yum install ruby-devel
yum install make
yum install gcc
You should be using Ruby 1.9.x, to upgrade Ruby:
sudo yum install ruby19
and also
sudo yum install ruby19-devel
sudo yum install make
sudo yum install gcc
If you've installed rvm, make sure to use rvm gem install rails
THe problem has nothing to do with RVM. The problem is you need ruby source header files. Compile ruby from source(RVM does that) or install the appropiate headers for your ruby version.
What is amazon linux(there is not such thing) ? is it ubuntu or what ?
How did you installed ruby ? what does ruby -v says ?
Related
I'm trying to install azure_mgmt_storage on Ubuntu 14.04.5 LTS. (And I'm new to Linux and Ruby.) Here's the command I tried:
sudo gem install azure_mgmt_storage
Building native extensions. This could take a while...
ERROR: Error installing azure_mgmt_storage:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext
/usr/bin/ruby2.4 -r ./siteconf20180221-102454-dq4ty1.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
I've have Rails 4.02 installed, and Ruby 2.4.3p205 (2017-12-14 revision 61247).
Based on another post, I also ran these:
sudo apt-get install ruby-dev
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-dev
How do I get ruby.h installed?
Thanks!
Well I suspect you actually need ruby2.4-dev if you're using ruby 2.4. But I'd recommend not using system ruby and installing gems globally with sudo in the first place. Using a ruby environment manager such as rbenv is the best way to avoid dependency hell. Here's a good overview of the available options: http://kgrz.io/programmers-guide-to-choosing-ruby-version-manager.html
I've had the same problem, and finally solved it by:
apt-get --reinstall install ruby
I am trying to install rails on an amazon-linux instance, but I keep getting the same error reported in this question:
[ec2-user#xxx.xxx ~]$ sudo gem install rails --no-ri --no-rdoc
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /usr/local/share/ruby/gems/2.3/gems/nokogiri-1.7.2/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170529-26560-9zyb13.rb extconf.rb
Note that I manually upgraded ruby to 2.3
[ec2-user#xxx.xxx ~]$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]
I've also tried with another versions of rails (I'd like to install the latest, 5.1.1), with also no luck
sudo gem install rails --version 5.1.1 --no-ri --no-rdoc
sudo gem install rails --version 5.0.0 --no-ri --no-rdoc
sudo gem install rails --version 4.2.8 --no-ri --no-rdoc
Is this possible at all or do I need to downgrade ruby to 2.0?
It seems the error occurred while compiling nokogiri.
The nokogiri docs says
Troubleshooting Ubuntu / Debian Installation
If you have issues, first make sure you have all the tooling necessary to compile C extensions:
sudo apt-get install build-essential patch
It’s possible that you don’t have important development header files installed on your system. (This has never happened to me personally, but I have it on good authority that otherwise good and noble Ruby developers run into this.) Here’s what you should do if you should find yourself in this situation:
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
I'm running Crunchbang 11 (Debian-based).
I'm trying to install Ruby on Rails, like this:
gem install rails --version 4.0.0
I get the error "Failed to build gem native extension".
My ruby is version 2.0.0p247, my RubyGems is 2.0.0.
What's the issue here?
This is the full error output:
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
creating Makefile
make
compiling atomic_reference.c
linking shared-object atomic_reference.so
make install
/usr/bin/install -c -m 0755 atomic_reference.so /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/lib/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux
/usr/bin/install: cannot create regular file `/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/lib/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/x86_64-linux': No such file or directory
make: *** [install-so] Error 1
Gem files will remain installed in /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10 for inspection.
Results logged to /home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/gems/atomic-1.1.10/ext/gem_make.out
My env:
ORBIT_SOCKETDIR=/tmp/orbit-erlkoenig
SSH_AGENT_PID=2695
rvm_bin_path=/home/erlkoenig/.rvm/bin
GEM_HOME=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247
SHELL=/bin/bash
TERM=xterm-256color
XDG_SESSION_COOKIE=9e0343c07c890bd2d60ee6a750f36c6c-1373892339.852749-193038580
IRBRC=/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/.irbrc
WINDOWID=39845892
GNOME_KEYRING_CONTROL=/home/erlkoenig/.cache/keyring-g6PRS5
MY_RUBY_HOME=/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247
USER=erlkoenig
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
rvm_path=/home/erlkoenig/.rvm
SSH_AUTH_SOCK=/tmp/ssh-XVmUxMD7LHwi/agent.2651
rvm_prefix=/home/erlkoenig
PATH=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247/bin:/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247#global/bin:/home/erlkoenig/.rvm/rubies/ruby-2.0.0-p247/bin:/home/erlkoenig/.rvm/bin:/home/erlkoenig/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/erlkoenig/.rvm/bin:/home/erlkoenig/.scripts:/home/erlkoenig/.scripts/netlogo-5.0.3:/opt/node/bin
MAIL=/var/mail/erlkoenig
PWD=/home/erlkoenig
EDITOR=vim
GNOME_KEYRING_PID=2575
LANG=en_US.UTF-8
rvm_env_string=ruby-2.0.0-p247
rvm_version=1.21.9 (stable)
SHLVL=1
HOME=/home/erlkoenig
rvm_ruby_string=ruby-2.0.0-p247
LOGNAME=erlkoenig
GEM_PATH=/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247:/home/erlkoenig/.rvm/gems/ruby-2.0.0-p247#global
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9eOdnYZelY,guid=a5db4ca68e107a48a04c8b8e51e3eef4
DISPLAY=:0.0
RUBY_VERSION=ruby-2.0.0-p247
XAUTHORITY=/home/erlkoenig/.Xauthority
COLORTERM=gnome-terminal
_=/usr/bin/env
Rails 4.0 needs RubyGem version 2.0.3, Just update your system by using following command
gem update --system 2.0.3
Run the following command:
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
Then,
sudo gem install rails
Just a follow up ... on different solution...
it may be that you are on a mac and rails cannot find the right compiler for c headers.
just install xcode from apps store / homebrew or go to terminal ...
$ xcode-select --install
complete the installation and agree on the licensing etc, then ...
$ sudo gem install rails
Got the same issue when installing rails with the command
"gem install rails -v 5.1.2" on windows7, solved after installing "MSYS2 and MINGW development toolchain" (command ridk install then option 3)..It took a while to finish the installation and then i installed rails without any problem
For me this helped:
sudo apt-get install ruby-dev
I could solve this way
rvm use ruby --install --default
and then try again.
gem install rails --no-document
This worked for me:
sudo ln -s /bin/mkdir /usr/bin/mkdir
I kept encountering this error when I ran gem install rails -v 5.2.0:
make: /usr/bin/mkdir: Command not found
make: *** [Makefile:199: .sitearchdir.-.racc.time] Error 127
make install failed, exit code 2
So I ran this command and it fixed it for me:
sudo ln -s /bin/mkdir /usr/bin/mkdir
Originally found: https://stackoverflow.com/a/64653052
Try
sudo gem install rails --version 2.0
to install libraries.
For anyone got the error:"Failed to build gem native extension”, while running sudo gem install rails, and it said somethings about "nokogiri".
It is possible because you are using the same ruby version as system is using (for mac user). The solution would be install RVM, use RVM to install another ruby version.
So now you have 2 Ruby versions on your machine, RVM will automatically switch to the newly installed version. now, you can run gem install rails without error and without sudo as well.
i'm running elementary os 5 and what i do is.
sudo gem update --system
and then try again.
sudo gem install rails
On Fedora 30, I ran into this problem "Failed to build gem native extension". The log error was "gcc: fatal error: cannot read spec file ‘/usr/lib/rpm/redhat/redhat-hardened-cc1’: No such file or directory". The solution was found here.
If you installed all the above, but the extensions would still not compile, you are probably running a Fedora image that misses redhat-rpm-config package. In that case gcc compiler would complain about one of the following:
gcc: error: conftest.c: No such file or directory
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
To solve this, simply run sudo dnf install redhat-rpm-config.
While installing rails 7 when I ran the command
sudo gem install rails
I got the same errors. I tried several suggestions, but in vain. At last one suggestion from the web helped me. I have been asked to run following command :
sudo apt-get install libmagickwand-dev
and then try again installing rails. Here is the link to that site : https://askubuntu.com/questions/600068/cant-install-a-ruby-package-failed-to-build-gem-native-extension
It worked !!!
I had the same error when installing rails, but I solved it by running the command: gem install rails without adding sudo.
I got a similar error installing rails 7.0.4 because of websocket-driver 0.7.5
Building native extensions. This could take a while...
ERROR: Error installing websocket-driver:
ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
/usr/local/bin/ruby -I /usr/local/lib/ruby/3.1.0 -r ./siteconf20221124-7-9o2qxo.rb extconf.rb
creating Makefile
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\= clean
current directory: /usr/local/bundle/gems/websocket-driver-0.7.5/ext/websocket-driver
make DESTDIR\=
make failedNo such file or directory - make
Gem files will remain installed in /usr/local/bundle/gems/websocket-driver-0.7.5 for inspection.
Results logged to /usr/local/bundle/extensions/aarch64-linux/3.1.0/websocket-driver-0.7.5/gem_make.out
The following command solved my problem
apt install -y build-essential
Getting an error when trying to install the gem devise, the installation is stopping on
the gem bcrypt-ruby:
$ gem install bcrypt-ruby
Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
I'm running OSX 10.6.7 with Ruby under RVM.
I reinstalled the lastest version of xcode & reinstalled Ruby 64bit, Rails and all the gems.
I had the same problem installing under OSX 10.7.3. When installing the gem, my error message was:
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
creating Makefile
make
compiling bcrypt_ext.c
make: /usr/bin/gcc-4.2: No such file or directory
make: *** [bcrypt_ext.o] Error 1
Looks like the gem is looking for gcc-4.2 but I only had a file called gcc. Now since I had just installed the latest Xcode (4.3), I knew that my C compiler was compliant but the gem had gcc-4.2 hardcoded into it. So my solution was:
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
The linking worked like a charm.
Looks like there might be some info missing here - for me, this was due to a brew install of gcc. gcc was in /usr/bin, but not gcc-4.2. So I just did the following:
$ cd /usr/bin
$ sudo ln -s gcc gcc-4.2
which creates a link, gcc-4.2, which the gem is looking for that goes back to gcc.
Hope that helps.
It requires to install ruby-dev before installing bcrypt-ruby.
If you are using Ubuntu, run
sudo apt-get install ruby1.9.1-dev
or
sudo apt-get install ruby1.8-dev
based on RUby version.
I'm using RVM & I kept having this issue whenever installing gems with native extensions (bcrypt-ruby, bson-ext, json, eventmachine, nokogiri, linecache19, etc.)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
Only way I could finally get things working was to uninstall then re-install ruby.
rvm remove 1.9.2
rvm install 1.9.2
Thanks to tip from #doublebee here:
https://github.com/flori/json/issues/78#issuecomment-1499920
You only need use rvm (ruby version manager)
rvm uninstall 1.9.3
and then
rvm install 1.9.3
looks this error is on build of rvm 1.9.3, but uninstall and reinstalling fix the problem with bcrypt-ruby 3.0.1
sudo apt-get install ruby1.9.1-dev
whoked charm for me! Thanks a lot
Well, it works with Ruby 1.9.2 under RVM on MacOS 10.6.7:
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
$ gem install bcrypt-ruby
Fetching: bcrypt-ruby-2.1.4.gem (100%)
Building native extensions. This could take a while...
Successfully installed bcrypt-ruby-2.1.4
1 gem installed
Installing ri documentation for bcrypt-ruby-2.1.4...
Installing RDoc documentation for bcrypt-ruby-2.1.4...
Try rvm notes and see if it says you need to install anything.
If you are using version 1.8 the required packages for bcrypt are in the dev bundle. Try using
$sudo apt-get install ruby1.8-dev
then
$gem install bcrypt-ruby
This fix work for me on ubuntu on osx use homebrew, macports whatever:
sudo apt-get install ruby1.9.1-dev
I think you need to reinstall bundler gem.
gem install bundler
and then
bundle install
I'm trying to get Rails to work with PostgreSQL. Apparently one thing I need to do along the way is sudo gem install pg. When I do that, I get this:
jason#buster:~/projects$ sudo gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:2:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:2
Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /var/lib/gems/1.8/gems/pg-0.10.0/ext/gem_make.out
I've Googled and tried a few things based on what I've found but nothing seems to help. Any advice? I'm on Ubuntu.
You need to install your distro ruby-dev (or devel) package otherwise you won~t be able to build any ruby C extensions.
I'm not on ubuntu, but you package-manager command might be somewhat like this:
$ sudo apt-get install ruby-dev build-essential
On Ubuntu:
$ sudo apt-get install postgresql-client libpq5 libpq-dev
$ sudo gem install pg