Programing

gem을 설치할 수 없음-gem 기본 확장을 빌드하지 못했습니다-해당 파일을로드 할 수 없습니다 — mkmf (LoadError)

crosscheck 2020. 6. 1. 07:55
반응형

gem을 설치할 수 없음-gem 기본 확장을 빌드하지 못했습니다-해당 파일을로드 할 수 없습니다 — mkmf (LoadError)


루비 1.9.3

Gemfile의 일부

#...............
gem "pony"
gem "bcrypt-ruby", :require => "bcrypt"
gem "nokogiri" 
#..................

보석을 설치하려고 할 때 오류가 발생합니다

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.

그런 다음이 일을하고 있습니다

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

오류도 발생합니다.

내가 놓친 게 무엇입니까?


비슷한 질문이 있습니다.

일반적으로 해결책은 다음과 같습니다.

sudo apt-get 설치 ruby-dev

또는 루비 버전에 따라 작동하지 않으면 다음과 같이 실행 하십시오 .

sudo apt-get 설치 루비 1.9.1-dev

문제를 해결해야합니다.


그래도 작동이 안되는? ruby-dev를 설치 한 후 다음을 시도하십시오 :

sudo apt-get 설치 확인


jquery-rails를 설치하려고하는 것과 동일한 문제가 발생했습니다. 수정은

sudo apt-get install zlibc zlib1g zlib1g-dev

다른 버전의 루비를 설치해야한다는 것을 알았습니다. 그래서 명령을 실행

$ 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++

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'


For WSL (Windows Subsystem for Linux) you need install build-essential package:

sudo apt install build-essential

  1. Make sure ruby-dev is installed
  2. Make sure make is installed
  3. 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).

It also helps to ensure libmysqlclient-dev is installed (Ubuntu 14.04)


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.

참고URL : https://stackoverflow.com/questions/13767725/unable-to-install-gem-failed-to-build-gem-native-extension-cannot-load-such

반응형