Installing bcrypt gem failed - ruby-on-rails

gem install bcrypt
Building native extensions. This could take a while...
ERROR: Error installing bcrypt:
ERROR: Failed to build gem native extension.
/Users/mohit/.rvm/rubies/ruby-1.9.3-p547/bin/ruby extconf.rb
creating Makefile
make clean
make
compiling bcrypt_ext.c
make: /usr/local/opt/gcc46/bin/gcc-4.6: No such file or directory
make: *** [bcrypt_ext.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/mohit/.rvm/gems/ruby-1.9.3-p547/gems/bcrypt-3.1.9 for inspection.
Results logged to /Users/mohit/.rvm/gems/ruby-1.9.3-p547/extensions/x86_64-darwin-13/1.9.1/bcrypt-3.1.9/gem_make.out
Edit with additional info from the OP:
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ brew doctor
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be
undone should you later need to do so for some reason.
cd /usr/local/Library && git stash && git clean -d -f
$ brew info gcc
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in require':
cannot load such file -- global (LoadError) from
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:
in require' from /usr/local/Library/brew.rb:16:in `<main>'
$ gcc -v
Configured with:
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0 Thread model: posix
$ ls -ladg /usr/local/opt/gcc*
No such file or directory

OSX help
Try installing XCode, which tends to be a huge download:
$ xcode-select --install
If the result is anything like this message below, that's ok for now.
command line tools are already installed,
use "Software Update" to install update
Update OSX to ensure it's ok and current:
Apple Menu -> About This Mac -> Software Update
Verify you have a current system, 10.10 as of this writing:
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10
BuildVersion: 14A389
Brew help
If you use the homebrew package manager, what version? (Please post output)
$ brew --version
Verify brew is healthy:
$ brew doctor
If the doctor finds any errors, fix these. For example, doctor may say to do this, so do it:
cd /usr/local/Library && git stash && git clean -d -f –
When doctor says everything is fine, then bring brew current:
$ brew update
$ brew upgrade
Is homebrew adding GCC? (Please post output)
$ brew info gcc
GCC help
Is GCC available?
$ command -v gcc
/usr/bin/gcc
See if your CC compiler variable is blank or set. (Please post the output)
$ echo $CC
What GCC version are you running? (Please post the output)
$ gcc -v
...
Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn)
...
Do you have any GCC installed where Ruby is looking? (Please post the output)
$ ls -ladg /usr/local/opt/gcc*
lrwxr-xr-x 1 admin 21 Dec 18 16:41 /usr/local/opt/gcc -> ../Cellar/gcc/4.9.2_1
Root gem help
Does the gem install if you're root?
$ sudo su -
$ gem install bcrypt

The root problem here is that ruby itself comes with bcrypt version 3.1.5 which is having bugs with the newer updates. However when you install or uninstall the bcrypt you are leving behind bcrypt-ruby which it always asks for first and hence all what you are doing won't go through so what to do ? 1- uninstall bcrypt and bcrypt-ruby by running these two commands:
$ gem uninstall bcrypt
and
$ gem uninstall bcrypt-ruby
2- Install it again with
gem install bcrypt --platform=ruby
In your Gemfile write gem 'bcrypt','~>3.1.11'
NOW as i write these lines the latest version is 3.1.11 but whatever version is updated just add it from their gem page. Run bundle install and it should work just fine.
I hope you fully understand the solution and the mechanism of it hence you would know that bundle install might cause the same issue so you have to repeat this process and it'll work again.

Stuck working on an old project I was able to get the gem installed by using the following steps (check you own paths - don't just copy paste):
1) Install the specific version of gcc required (check the version) :
brew install gcc46
2) Symlink the installed gcc directory :
ln -s /usr/local/Cellar/gcc\#4.6/4.6.4_2 /usr/local/Cellar/gcc46/4.6.4
3) Install the gem reporting the error (check your gem name)
gem install bcrypt-ruby -v '3.0.1'

Related

gem native extension error while installing cocoapods

Am trying to reinstall cocoapods in my MacBook air after changing my SSD, now am getting this bellow error.
sudo gem install cocoapods
Building native extensions. This could take a while... ERROR: Error
installing cocoapods: ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r
./siteconf20200308-27204-6l0a5q.rb extconf.rb mkmf.rb can't find
header files for ruby at
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in
/Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection. Results
logged to
/Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
Open Terminal
curl -L https://get.rvm.io | bash -s stable
Reopen Terminal
rvm install ruby-2.6
rvm use ruby-2.6.3
rvm --default use 2.6.3
From MahmoudKhaled's comment on
link
For me it worked by installing a previous version of cocoapods
sudo gem install cocoapods -v 1.8.4
Hope it helps
This error can be fixed by updating ruby to it's latest version version 2.3.0 is having that issue.
You can update the ruby version to latest one by following below steps.
Check the version of Ruby installed on your Mac
Open terminal and type:
ruby -v
Install the Ruby Version Manager rvm
In terminal,
curl -L https://get.rvm.io | bash -s stable
Once this command has finished running you may need to restart your terminal for rvm to be recognised.
Install the latest version of Ruby
rvm install ruby-[version]
In my case this was
rvm install ruby-2.7.1
This took a while to run as it had to install a lot of dependencies and asked for my permission a couple of times.
Set the latest version of Ruby as the one you want to use
You should now be running the latest version of Ruby. You can check as before with the ruby -v command as in step 1. If you’re find that you’re not, you can set this manually. In terminal type:
rvm use ruby-2.7.1
If you want to set this latest version of Ruby as the default version, in terminal type:
rvm --default use 2.7.1
After that done you can get your below command working for upgrading cocoapods
sudo gem install cocoapods
Probably you have not selected the Command Line Tool in Xcode > Preference > Location after an update.
The sudo gem install cocoapods command works after the tool is selected in Xcode.
Open terminal
xcode-select --install
Reopen Terminal
sudo gem install cocoapods
That's it!
Error: gem native extension error while installing cocoapods
Answer: Follow below 3 Steps issue will be fixed.
Step 1: Open XCode go to below path
XCode > Preferences > Locations > Command Line Tools (select-Xcode)
Step 2: Open Terminal- Paste the below Command
curl -L https://get.rvm.io | bash -s stable
Reopen Terminal -Paste the below Commands
Note: It will take 3-5 minutes
rvm install ruby-2.6
rvm use ruby-2.6.3
rvm --default use 2.6.3
Step3:
Open Terminal- Type below Command
sudo gem install cocoapods
Now gem native extension error while installing cocoapods will not come
Issue resolved.
I had the same error, I was unable to upgrade cocopods and the problem was that homebrew was failing to update.
I noticed that when trying to install a new ruby version with nvm, it was failing because it was trying to run homebrew update. So it seems nvm and homebrew are connected
I followed the instructions here: https://github.com/Homebrew/brew/issues/9420
basically
brew update (was failing)
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
brew update (successful)
brew install cocoapods
It didn't solve the error, but upgraded cocoapods in another way.
enter image description here
I used all the codes before and showed up there, when I tried to run flutter doctor for the millesimal time...
CocoaPods 1.8.4 out of date (1.10.0 is recommended)
I just changed to: sudo gem install cocoapods -v 1.10.0
and apparently installed the cocoapods.
brew cleanup -d -v
brew install /usr/local/bin cocoapods
Short answer:
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable --ruby
sudo gem install cocoapods
For detail pls refer: another post's answer

El Capitan Update rails

Just updated my system to El Capitan and when launching the rails server (that worked perfectly on Yosemite) I get the following warning.
Ignoring bcrypt-3.1.10 because its extensions are not built. Try: gem pristine bcrypt --version 3.1.10
Ignoring bcrypt-ruby-3.1.2 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.1.2
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
when running the referenced commands I get:
-bash: bundle: command not found
rails update
Ignoring json-1.8.1 because its extensions are not built. Try: gem pristine json --version 1.8.1
Ignoring json-1.8.2 because its extensions are not built. Try: gem pristine json --version 1.8.2
Ignoring json-1.8.3 because its extensions are not built. Try: gem pristine json --version 1.8.3
Ignoring nokogiri-1.6.6.2 because its extensions are not built. Try: gem pristine nokogiri --version 1.6.6.2
Ignoring atomic-1.1.14 because its extensions are not built. Try: gem pristine atomic --version 1.1.14
Ignoring atomic-1.1.14 because its extensions are not built. Try: gem pristine atomic --version 1.1.14
Ignoring bcrypt-ruby-3.0.1 because its extensions are not built. Try: gem pristine bcrypt-ruby --version 3.0.1
Ignoring binding_of_caller-0.7.2 because its extensions are not built. Try: gem pristine binding_of_caller --version 0.7.2
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
Could not find bcrypt-3.1.10 in any of the sources
Run `bundle install` to install missing gems.
also tried running:
sudo gem pristine --all
Restoring gems to pristine condition...
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0/gems/CFPropertyList-2.2.8/README
So now, it can't even find the bundle install path. Seems like the update has really messed it up.
When I run gem pristine --all I get the following:
Restored bcrypt-ruby-3.1.5
Skipped bigdecimal-1.2.0, it is a default gem
Building native extensions. This could take a while...
Restored binding_of_caller-0.7.2
Restored bootstrap-sass-3.3.5.1
Restored builder-3.2.2
Restored builder-3.1.4
Restored bundler-1.10.6
Restored bundler-1.9.6
Building native extensions. This could take a while...
ERROR: While executing gem ... (Gem::Ext::BuildError)
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151001-3494-1jca623.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/universal-darwin15/ruby/config.h', needed by `breakpoint.o'. Stop.
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/byebug-6.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-15/2.0.0/byebug-6.0.2/gem_make.out
Solution is in the following link.
Hardware
Upgrade to El Capitan, with Homebrew & Ruby
... and Xcode and Java, etc.
If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.
After the installs and forced reboots my 27" Thunderbolt display wouldn't display anything. Unplug, replug didn't help. One more reboot fixed it.
Software
In order...
Xcode
The El Capitan install wiped out my Xcode install, so I had to search for it in the App Store and reinstall. I now believe that I deleted Xcode awhile ago and forgot, hence the reinstall. I did this on a machine that I rarely use.
After Xcode is finished installing, open iTerm, which I use as a Terminal.app replacement, or Terminal.app if you are so inclined.
∴ xcode-select --install
xcode-select: note: install requested for command line developer tools
A dialog opened, I chose "Install", which finished in about a minute.
Java
Next, run java, which prompts with a dialog that has a button "More Info" which takes you to a website where you can accept the license and download the Java .dmg file. You need the JDK, not the JRE, if you intend to run java command-line based tools.
Unable to find any JVMs matching version "1.7".
No Java runtime present, try --request to install.
∴ java
No Java runtime present, requesting install.
Once downloaded, open the .dmg (for me it was jdk-8u60-macosx-x64.dmg) and install, then restart iTerm.
∴ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Apps like RubyMine should work now, well, at least launch.
Homebrew
The doctor informed me of several warnings which I took care of as instructed.
∴ brew doctor
∴ sudo chown -R $(whoami):admin /usr/local
∴ cd /usr/local/Library && git stash && git clean -d -f
∴ cd ~
∴ brew prune
∴ brew unlink qt5
Then I was able to update Homebrew.
∴ brew update
qt5
I know the capybara-webkit gem will require qt5, and I know qt is one of the primary remaining pain points in homebrew / El Capitan issues tracker, so I decided to get it out of the way first.
∴ brew uninstall qt5
∴ brew install qt5
∴ brew linkapps qt5
∴ brew link --force qt5
That last line is required to make qmake available. Check with which qmake. Otherwise you will end up with this on the Capybara install later on:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/pboling/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20150930-48087-1vw6bye.rb extconf.rb
sh: qmake: command not found
*** extconf.rb failed ***
GPG
Some software is now being signed with GPG, like RVM, for example, so install it.
∴ brew install gpg
RVM
My Ruby was working, but I was having trouble with some native gem installations, so I decided to start fresh with a Ruby compiled against all the new homebrew and Xcode libraries.
∴ rvm implode
Implode actually failed to remove the main ~/.rvm directory due to permissions issues. I had to sudo remove it.
∴ sudo rm -rf /Users/pboling/.rvm
Follow the instructions here for installing RVM, I installed the development version, hoping it would have more El Capitan fixes in it:
∴ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
∴ \curl -sSL https://get.rvm.io | bash
The main app I currently work on is using Ruby 2.1.2, so I install that first, and then go to the project directory to have the gemset created and to bundle.
∴ rvm install 2.1.2
∴ cd ~/project
∴ gem install bundler -v 1.9.7
∴ bundle install
Bundler version 1.9.7 because that's what Heroku is on, and I want to stay in sync, because 1.10* changed things that make the Gemfile.lock incompatible with 1.9.7 on the deployed server (for me, with multiple gem sources, private gem server, etc).
Postgres
I also took the opportunity to upgrade to the latest Postgres.app. Alternatively you can install postgres with brew install postgres. I choose Postgres.app begause it is supported directly by Heroku, and I like to think there is a parity win there somewhere.
You should try RVM or RBENV or whatever the flavor of the week is. This will allow you to easily manage your Ruby Interpreters and Gemsets on a per project basis. I still use RVM and I'm quite happy with it.
https://rvm.io/rvm/install

Unable to require openssl when initialling rails

I have the error below when installing rails on osx maverick. OpenSSL has been installed already. Does anyone know how to fix this issue?
$ gem install rails
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
You may need to update your OpenSSL CA Bundle, per these instructions from chruby about Ruby 2.1.2 which state:
Install 2.1.2
Note: MRI 2.1.2 requires OpenSSL >= 1.0.1.
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
tar -xjvf ruby-2.1.2.tar.bz2
cd ruby-2.1.2
./configure --prefix=/opt/rubies/ruby-2.1.2
make
sudo make install
Note: OS X users must update their OpenSSL CA cert bundle and properly set ./configure --with-opt-dir to compile against Homebrew's libraries:
wget http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.2.tar.bz2
tar -xjvf ruby-2.1.2.tar.bz2
cd ruby-2.1.2
./configure --prefix="$HOME/.rubies/ruby-2.1.2" --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm):$(brew --prefix libffi)"
make
sudo make install
For me, it was enough to just update my OpenSSL CA cert bundle via Homebrew and then reinstall Ruby using ruby-install
brew tap raggi/ale
brew install openssl-osx-ca
ruby-install ruby 2.1.2
After I performed the above steps, the issue stopped presenting itself.
For me... I had tried installing ruby 2.1.2 with ruby-install (since I use chruby for my ruby version manager). I had tried manually installing openssl with homebrew, etc. But I still couldn't get ruby-install to successfully build ruby 2.1.2. I've also had similar issues in the past with installing rubies and ruby-build worked then so I gave I gave it a shot here and it worked! As I understand it, ruby-build is the installer used by rbenv.
What I did was:
rm -rf ~/.rubies/ruby-2.1.2 (This is where my ruby installs are installed at.)
brew remove --force openssl
brew install ruby-build
restart console to be safe
ruby-build 2.1.2 ~/.rubies/ruby-2.1.2
And success! ruby-build seems to be much smarter than ruby-install at successfully installing weird dependencies. I'm done with ruby-install at this point -- it's given me too many problems! (brew remove --force ruby-install)
I've had a similar issue.
A fix to rvm was introduced just yesterday, and it was not yet merged with rvm master branch, so this is how you do it:
rvm get branch /bugfix/3923_set_osx_brew_openssl_compiler_config
rvm install 2.4.0
gem install rails
If that works for you, go to the issue and tell the developer how much you appreciate his effort:
Recently I was struggling with ruby installations due to the recent auto-update in openssl version from 1.0 to 1.1.
I found out that the ruby version < 2.4 does not work with openssl version > 1.0.
I was not even able to revert back the openssl to 1.0 version because other libs has dependencies on it.
No other solution except the one given below worked for me:
brew install rbenv/tap/openssl#1.0
rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/openssl#1.0'
gem update --system
Now my ruby runs with openssl 1.0 whereas all other libraries are running on the default openssl version 1.1.
secure server is the reason of this issue. You can Install it by using this command:
gem install rails --source http://rubygems.org
by default its using https://rubygem.org as the source for the gem.
$ gem install rails ERROR: While executing gem ... (Gem::Exception) Unable to
require openssl, install OpenSSL and
rebuild ruby (preferred) or use non-HTTPS sources
so we can specify a source, http//:rubygems.org which is a non-HTTPS source.

Error when installing Ruby on Rails: "Failed to build gem native extension"

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

Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)

Ruby 1.9.3
The part of Gemfile
#...............
gem "pony"
gem "bcrypt-ruby", :require => "bcrypt"
gem "nokogiri"
#..................
When I'm trying to install gems, I get an error
alex#ubuntu:~/$ bundle
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Enter your password to install the bundled RubyGems to your system:
#####............................................................
Installing bcrypt-ruby (3.0.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:36:in `<main>'
Gem files will remain installed in /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /home/alex/.bundler/tmp/5526/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
An error occurred while installing bcrypt-ruby (3.0.1), and Bundler cannot continue.
Make sure that `gem install bcrypt-ruby -v '3.0.1'` succeeds before bundling.
Then I'm doing this
sudo gem install bcrypt-ruby -v '3.0.1'
Building native extensions. This could take a while...
ERROR: Error installing bcrypt-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:36:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
and getting an error as well.
What did I miss?
There are similar questions:
`require': no such file to load -- mkmf (LoadError)
Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04
Usually, the solution is:
sudo apt-get install ruby-dev
Or, if that doesn't work, depending on your ruby version, run something like:
sudo apt-get install ruby1.9.1-dev
Should fix your problem.
Still not working? Try the following after installing ruby-dev:
sudo apt-get install make
For WSL (Windows Subsystem for Linux) you need install build-essential package:
sudo apt install build-essential
Just finished a 2 hour wild goose chase trying to solve this. None of the posted answers worked for me. Im on a Mac (Mojave Version 10.14.6, Xcode Version 11.3).
It turns out the ruby file headers were missing so i had to run open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
That didnt work for me at first because the version of CommandLineTools i had installed did not have the "Packages" folder. So i uninstalled and reinstalled like this:
rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Then i ran the previous command again:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
After install the error was fixed!
I had the same issue trying to install jquery-rails. The fix was
sudo apt-get install zlibc zlib1g zlib1g-dev
For MacOS users:
Just do this and easily it will solve your problem:
brew install cocoapods
In case anyone in the future had this problem, I'm using a Mac and just had to install the Command Line Tools using 'xcode-select --install'
I found that I needed to install another version of ruby. So running the command
$ sudo apt-get install ruby1.9.1-dev
and then attempt to install the extension
If you run into issues where it is telling you that you don't have g++ you can run the following command to install it
$ sudo apt-get install g++
Make sure ruby-dev is installed
Make sure make is installed
If you still get the error, look for suggested packages. If you are trying to install something like gem install pg you will also need to install the lib libpq-dev (sudo apt-get install libpq-dev).
I created a small hackMD to install cocoapods on MacOS 10.15 (Catalina) and 11 (Big Sur)
https://hackmd.io/#sBJPlhRESGqCKCqV8ZjP1A/S1UY3W7HP
Installing Cocoapods on MacOS Catalina(MacOS 10.15.X) and Big Sur (MacOS 11)
Make sure you have xcode components are installed.
Download 'Command Line Tools' (about 500MB) directly from this link (Requires you to have apple account)
https://developer.apple.com/downloads/index.action
Install the downloaded file
Click on Install
Install COCOAPODS files in terminal
sudo gem install -n /usr/local/bin cocoapods
This worked for me.
bundle config --global build.snappy --with-opt-dir="$(brew --prefix snappy)"
It also helps to ensure libmysqlclient-dev is installed (Ubuntu 14.04)
What ended up working for me after a few hours of pain..
if you're running brew..
brew install ruby
in the terminal output/log, identify the path where ruby was installed, brew suggests 'You may want to add this to your PATH', so that's what we'll do. For example, mine is
/usr/local/lib/ruby/gems/3.0.0/bin
Add this to your path by running (omitting braces)
echo 'export PATH"{the_path_you_found_above}:$PATH"' >> ~/.bash_profile
then update your environment by running
source ~/.bash_profile
now, try running your install, i.e.,
sudo gem install middleman
If you are a mac user you must need to update the clang version being used
I burnt hours searching this and installed uninstalled xcode commandline tools but it didn't help.
I ran gcc -v and Apple clang version 11.0.0 (clang-1100.0.33.8 was the output.
Then I ran xcode-select -s /Library/Developer/CommandLineTools/ and clang version was updated to Apple clang version 12.0.0 (clang-1200.0.32.29).
bundle install was successful after that.
I hope this may help.
I was making a word search app and I had to install cocoapods and after formatting my mac and reinstalling xcode, I still got the error when I wanted to install cocoapods.
And the solution for this was the following:
It looks like CocoaPods 1.9.0, the latest version as of this writing, depends on a newer version of Ruby than 2.3.7. But macOS Mojave only includes Ruby 2.3.7, so you have a few different options.
Upgrade to macOS Catalina and get Ruby 2.6.3
Use Ruby Version Manager to install a newer version of Ruby
Install an older version of CocoaPods
sudo gem install cocoapods -v 1.8.4
I did 3:
sudo gem install cocoapods -v 1.8.4
In Mac, for me this works:
CONFIGURE_OPTS="--enable-shared" rbenv install 2.2.2
After some search for a solution, it turns out the -dev package is needed, not just ruby1.8. So if you have ruby1.9.1 doing
sudo apt-get install ruby1.9.1-dev
or to install generic ruby version, use (as per #lamplightdev comment):
sudo apt-get install ruby-dev
should fix it.
Try to locate mkmf to see if the file is actually there.
first set your Xcode version on the terminal:
sudo xcode-select -switch /Applications/Xcode.app
then install:
sudo gem install cocoapods

Resources