web-dev-qa-db-ja.com

Rubyパッケージをインストールできません:gemネイティブ拡張のビルドに失敗しました

昨年、ブログに続いてRuby 2.1.0とpdfbeadsを32ビット12.04にインストールしました https://railssavvy.wordpress.com/2012/06/02/install_Ruby_and_Rails/ 動いた。 64ビット14.04にRuby 2.2.0をインストールしたようですが、pdfbeadsのインストール時に問題が発生しました。

  1. rvmとRubyのインストール:

    UbuntuリポジトリのRubyが機能しないと聞いたので(それがまだ当てはまるかどうかわかりません)、私は https://railssavvy.wordpress.com/2012/06/ 02/install_Ruby_and_Rails / rvmとRubyをインストールします。次の点で正しいことをしたかどうかはわかりません。

    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
    
    curl -L get.rvm.io | bash -s stable
    

    最初にcurl -L get.rvm.io | bash -s stableを最初に実行しましたが、その前にgpgコマンドを実行するように求められました。

    次に、行を〜/ .bashrcに追加します。

    PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
    

    〜/ .bash_profileへの数行:

    [[ -s "$HOME/.profile" ]] && source "$HOME/.profile"
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
    

    それから私は走った:

    source ~/.rvm/scripts/rvm
    rvm requirements
    rvm autolibs disable
    
    
    $ rvm install 2.2.0
    Already installed Ruby-2.2.0.
    To reinstall use:
    
        rvm reinstall Ruby-2.2.0
    

    既にRubyをインストールしたことがわかり、それから前のコマンドの出力を確認し、curl -L get.rvm.io | bash -s stableがすでにRubyをインストールしているようだとわかりました。それから私は走った:

    rvm --default use 2.2.0
    

    RvmとRubyを正しくインストールしましたか?それともそれを行うためのより良い方法はありますか?

  2. 次に、パッケージをインストールしますpdfbeads

    $  gem install  pdfbeads
    Building native extensions.  This could take a while...
    ERROR:  Error installing pdfbeads:
        ERROR: Failed to build gem native extension.
    
        /home/t/.rvm/rubies/Ruby-2.2.0/bin/Ruby -r ./siteconf20150322-21902-q15297.rb extconf.rb
    checking for Ruby version >= 1.8.5... yes
    checking for gcc... yes
    checking for Magick-config... no
    checking for pkg-config... yes
    checking for ImageMagick version >= 6.4.9... yes
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    checking for stdint.h... yes
    checking for sys/types.h... yes
    checking for wand/MagickWand.h... no
    
    Can't install RMagick 2.13.4. Can't find MagickWand.h.
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --Ruby=/home/t/.rvm/rubies/Ruby-2.2.0/bin/$(Ruby_BASE_NAME)
    
    extconf failed, exit code 1
    
    Gem files will remain installed in /home/t/.rvm/gems/Ruby-2.2.0/gems/rmagick-2.13.4 for inspection.
    Results logged to /home/t/.rvm/gems/Ruby-2.2.0/extensions/x86_64-linux/2.2.0/rmagick-2.13.4/gem_make.out
    t@ocean:/h/t/./archives$ man gem
    No manual entry for gem
    See 'man 7 undocumented' for help when manual pages are not available.
    

    私はこのリンクをたどります https://askubuntu.com/a/528798/1471 実行の提案

    rvm install 2.2.0-dev
    

    それでも同じエラーがあるようです:

    $  gem install  pdfbeads
    Building native extensions.  This could take a while...
    ERROR:  Error installing pdfbeads:
        ERROR: Failed to build gem native extension.
    
        /home/t/.rvm/rubies/Ruby-2.2.0/bin/Ruby -r ./siteconf20150322-24037-mauac1.rb extconf.rb
    checking for Ruby version >= 1.8.5... yes
    checking for gcc... yes
    checking for Magick-config... no
    checking for pkg-config... yes
    checking for ImageMagick version >= 6.4.9... yes
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    Package MagickCore was not found in the pkg-config search path.
    Perhaps you should add the directory containing `MagickCore.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'MagickCore' found
    checking for stdint.h... yes
    checking for sys/types.h... yes
    checking for wand/MagickWand.h... no
    
    Can't install RMagick 2.13.4. Can't find MagickWand.h.
    *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of necessary
    libraries and/or headers.  Check the mkmf.log file for more details.  You may
    need configuration options.
    
    Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --Ruby=/home/t/.rvm/rubies/Ruby-2.2.0/bin/$(Ruby_BASE_NAME)
    
    extconf failed, exit code 1
    
    Gem files will remain installed in /home/t/.rvm/gems/Ruby-2.2.0/gems/rmagick-2.13.4 for inspection.
    Results logged to /home/t/.rvm/gems/Ruby-2.2.0/extensions/x86_64-linux/2.2.0/rmagick-2.13.4/gem_make.out
    

    pdfbeadsパッケージをどのようにインストールできますか?

ありがとう!

3
Tim

Rubyのバージョンが正しく設定されているかどうかを確認するには、次を使用できます。

$ which Ruby
  /path/to/Ruby
$ Ruby --version
  Ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin13.0]

あなたの場合、Rubyはうまく設定されているように見えます。 Rvmは、ルビーの管理に役立つ単なるツールです。気に入らなければわかるでしょう。

Gemのインストールが失敗した理由の手がかりがあります。特に、

checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no                   <------   There's your problem
checking for pkg-config... yes
checking for ImageMagick version >= 6.4.9... yes

Gemを正常にビルドするために必要なライブラリがありません。 これ ソリューションは、リポジトリで利用可能であることを示唆しています。だから、あなたはそれをインストールできるはずです:

Sudo apt-get install libmagickwand-dev

これが完了すると、gemをインストールできるはずです。

gem install  pdfbeads

注:私はこのソリューションをテストしていませんが、より賢明な読者であれば、ここでubuntuを使用していないことに気付くかもしれません。これでソートできない場合は、コメントを残してください。

6
Kasisnu

これを試して。それは私のために働いた:

Sudo apt-get install Ruby-dev
Sudo gem install pdfbeads

参照: https://stackoverflow.com/a/26161563/243302

2
zarroc

また最近、RVMでこの問題に遭遇しました。

Compassをインストールしようとしましたが、Ubuntuの最近のクリーンインストールでネイティブバイナリで失敗しました。

解決策は、後で--disable-binaryの追加フラグを使用してRubyバージョン(2.3.0)を再インストールすることでした。これは、RVMに付属のコンパイル済みバイナリをインストールしないことを意味します。これは、ネイティブバイナリがマシンでコンパイルされることを意味します。これを完了するには時間がかかります。

したがって、この問題が発生している場合:

rvm reinstall --disable-binary 2.2.0

Rubyバージョンを、問題が発生しているバージョンに更新してください。

1

Sudo apt install build-essentialを実行すると、再び動作します。

Ubuntu 18.04、Ruby 2.5.1p57。

0
vuhung3990

WSL(Linux用Windowsサブシステム)の場合、build-essentialパッケージをインストールする必要があります。

Sudo apt install build-essential
0
Dmitry S.