安装bcrypt gem失败了

时间:2014-12-23 21:24:54

标签: ruby-on-rails ruby gem rubygems bcrypt-ruby

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

使用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 

3 个答案:

答案 0 :(得分:1)

OSX帮助

  1. 尝试安装XCode,这往往是一个巨大的下载:

    $ xcode-select --install
    
  2. 如果结果如下所示,那就可以了。

    command line tools are already installed, 
    use "Software Update" to install update
    
  3. 更新OSX以确保其正常且最新:

    Apple Menu -> About This Mac -> Software Update
    
  4. 在撰写本文时,确认您有一个当前系统,10.10:

    $ sw_vers
    ProductName: Mac OS X
    ProductVersion: 10.10
    BuildVersion: 14A389
    
  5. Brew帮助

    1. 如果您使用自制软件包管理器,那么什么版本? (请发布输出)

      $ brew --version
      
    2. 验证brew是否健康:

      $ brew doctor
      
    3. 如果医生发现任何错误,请修复这些错误。例如,医生可能会说这样做,所以这样做:

      cd /usr/local/Library && git stash && git clean -d -f – 
      
    4. 当医生说一切都很好的时候,然后带上冲泡电流:

      $ brew update
      $ brew upgrade
      
    5. 自制软件添加GCC吗? (请发布输出)

      $ brew info gcc 
      
    6. GCC帮助

      1. GCC是否可用?

        $ command -v gcc
        /usr/bin/gcc
        
      2. 查看您的CC编译器变量是空白还是已设置。 (请发布输出)

        $ echo $CC
        
      3. 你在运行什么GCC版本? (请发布输出)

        $ gcc -v
        ...
        Apple LLVM version 6.0 (clang-600.0.34.4) (based on LLVM 3.5svn)
        ...
        
      4. 你在Ruby看的地方安装了GCC吗? (请发布输出)

        $ 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
        
      5. Root gem help

        1. 如果您是root用户,是否会安装gem?

          $ sudo su -
          $ gem install bcrypt
          

答案 1 :(得分:0)

这里的根本问题是ruby本身带有bcrypt版本3.1.5,它有更新的更新错误。然而,当你安装或卸载bcrypt时,你会在bcrypt-ruby之后留下它总是要求的,所以你所做的一切都不会经过这样做怎么办? 1-通过运行以下两个命令卸载bcrypt和bcrypt-ruby:

$ gem uninstall bcrypt

$ gem uninstall bcrypt-ruby

2-用

重新安装
gem install bcrypt --platform=ruby

在你的Gemfile中写上gem'bcrypt','〜&gt; 3.1.11'

现在,当我写这些行时,最新版本是3.1.11,但无论更新版本,只需从他们的宝石页面添加它。运行bundle install,它应该可以正常工作。

我希望您完全理解它的解决方案和机制,因此您会知道捆绑安装可能会导致同样的问题,因此您必须重复此过程并且它将再次起作用。

答案 2 :(得分:0)

坚持一个旧项目,我可以通过以下步骤安装宝石(检查你自己的路径 - 不要只是复制粘贴):

1)安装所需的特定gcc版本(查看版本):

<table class="table table-bordered table-condensed">
                                <tr>
                                    <th>Days</th>
                                    <th>Date</th>
                                    <th>Calories</th>
                                    <th>Happiness</th>
                                    <th>Hunger</th>
                                    <th>Motivation</th>
                                </tr>
                                <tr>
                                    <td>1</td>
                                    <td id="day">{{dayArray[0]}}</td>
                                    <td id="calorie">{{calorieArray[0]}}</td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                </tr>
                                <tr>
                                    <td>2</td>
                                    <td id="day">{{dayArray[1]}}</td>
                                    <td id="calorie">{{calorieArray[1]}}</td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                </tr>
                                <tr>
                                    <td>3</td>
                                    <td id="day">{{dayArray[2]}}</td>
                                    <td id="calorie">{{calorieArray[2]}}</td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                    <td><input placeholder="0" /></td>
                                </tr>
                                <tr>

2)符号链接已安装的gcc目录:

brew install gcc46

3)安装报告错误的gem(检查你的宝石名称)

ln -s /usr/local/Cellar/gcc\@4.6/4.6.4_2 /usr/local/Cellar/gcc46/4.6.4