【问题标题】:Unable to do bundle install and gem install bundler -v 1.17.3 with ruby version ruby-1.8.7-p374无法使用 ruby​​ 版本 ruby​​-1.8.7-p374 进行捆绑安装和 gem install bundler -v 1.17.3
【发布时间】:2019-02-11 03:41:33
【问题描述】:

使用的操作系统:Mac OS High Sierra 版本:10.13.6

我有一个安装了以下 Ruby 版本的 RVM:


MAC-070618-A:website anujaw$ rvm list
   ruby-1.8.7-head [ i686 ]
   ruby-1.8.7-p358 [ i686 ]
=> ruby-1.8.7-p374 [ i686 ]
 * ruby-2.3.7 [ x86_64 ]
   ruby-2.4.0 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

在我的机器上本地运行应用程序所需的 Ruby 版本是:ruby-1.8.7-p374 我正在尝试执行bundle install 并出现以下错误:

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
    from /usr/local/bin/bundle:22:in `<main>'

当我像下面这样gem install bundler 时,我得到一个错误:


MAC-070618-A:website anujaw$ gem install bundler -v 1.17.3
ERROR:  Loading command: install (LoadError)
    no such file to load -- openssl
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

我已经安装了 OpenSSL,见下文:

    MAC-070618-A:website anujaw$ brew info openssl
    openssl: stable 1.0.2q (bottled) [keg-only]
    SSL/TLS cryptography library
    https://openssl.org/
    /usr/local/Cellar/openssl/1.0.2o_2 (1,792 files, 12.3MB)
      Poured from bottle on 2018-07-23 at 14:37:12
    /usr/local/Cellar/openssl/1.0.2q (1,794 files, 12.1MB)
      Poured from bottle on 2019-01-30 at 14:12:51
    From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
    ==> Caveats
    A CA file has been bootstrapped using certificates from the SystemRoots
    keychain. To add additional certificates (e.g. the certificates added in
    the System keychain), place .pem files in
      /usr/local/etc/openssl/certs

    and run
      /usr/local/opt/openssl/bin/c_rehash

    openssl is keg-only, which means it was not symlinked into /usr/local,
    because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

    If you need to have openssl first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

    For compilers to find openssl you may need to set:
      export LDFLAGS="-L/usr/local/opt/openssl/lib"
      export CPPFLAGS="-I/usr/local/opt/openssl/include"

    For pkg-config to find openssl you may need to set:
      export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

    ==> Analytics
    install: 465,985 (30 days), 1,553,385 (90 days), 6,076,848 (365 days)
    install_on_request: 59,235 (30 days), 217,436 (90 days), 854,397 (365 days)
    build_error: 0 (30 days)

请告知如何克服这个障碍?谢谢。

【问题讨论】:

  • 您的应用程序中运行的 ruby​​ 版本是什么。 $红宝石-v。这可能是由于 rvm 问题,请查看 stackoverflow.com/questions/5515331/…
  • @Bijendra 下面是 Ruby 版本:ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin17.7.0]

标签: ruby-on-rails ruby rubygems


【解决方案1】:

我已经遇到了这个问题,我解决了:

gem update --system

【讨论】:

    【解决方案2】:

    尝试针对您的问题运行这些命令。

    sudo gem install -n /usr/local/bin bundler -v 1.17.3

    然后,安装 Ruby 依赖项

    捆绑安装

    【讨论】:

      【解决方案3】:

      所以,我可以通过参考以下链接解决此错误:

      How to set correct Ruby version in gem environment

      主要问题是我的 Ruby gem (2.0.17) 与 ruby​​ 1.8.7 (2013-06-27 patchlevel 374) 不兼容 以下是我所做的步骤: 仅在下载 RubyGems 1.6.2 后,按照说明解压缩等

      所以:

      curl -O https://rubygems.org/rubygems/rubygems-1.6.2.tgz

      然后解压下载的文件;

      要使用您需要使用的 tar 提取 .tgz 文件,

      tar -xvzf /path/to/yourfile.tgz
      
      cd rubygems-1.6.2
      rvm ruby-1.8.7-p374
      ruby setup.rb
      gem update --system 1.8.25
      
      

      然后,运行 gem env 来检查您的 RubyGems 环境。希望没问题,然后运行gem install bundler -v 1.17.3

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-18
        • 2013-06-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多