Cannot install bcrypt-ruby on vagrant machine

2019-07-16 15:30发布

问题:

I have followed the instructions for setting up a vagrant rails dev box from https://github.com/rails/rails-dev-box. Unfortunately when I attempt to bundle I get the following:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/vagrant/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
creating Makefile

make "DESTDIR=" clean
sh: 1: make: not found

make "DESTDIR="
sh: 1: make: not found

make failed, exit code 127

Gem files will remain installed in /home/vagrant/.rvm/gems/ruby-2.0.0-p353/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /home/vagrant/.rvm/gems/ruby-2.0.0-p353/extensions/x86-linux/2.0.0/bcrypt-ruby-3.0.1/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.

When I try and run that gem install command I get the same issue. I have done some searching and am at a loss. Any input is greatly appreciated.

回答1:

This bcrypt-ruby gem is trying to compile native (c, c++) code. It looks like your VM is missing some tools required to compile this native code.

Get a shell to the VM:

vagrant ssh

Then installing these packages should solve the issue:

sudo apt-get install make g++ gcc libssl-dev

Run bundle install after that.