gem更新引起的错误:未定义的方法ssl_version

时间:2019-04-25 06:02:00

标签: ruby-on-rails ruby rubygems rvm macos-mojave

我尝试在macOS中更新gem,但发生以下错误:

$ RUBYOPT= gem update --system
ERROR:  While executing gem ... (NoMethodError)
    undefined method `ssl_version=' for #<OpenSSL::SSL::SSLContext:0x007f8561047638>
Did you mean?  ssl_timeout=

gem updategem install {package_name}的输出是相同的。

gem env versiongem --version的输出为:

  

3.0.3

openssl version的输出是:

  

LibreSSL 2.6.5

如何解决该问题?

macOS版本:10.14.4


gem env的输出:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.4.0 (2016-12-24 patchlevel 0) [x86_64-darwin16]
  - INSTALLATION DIRECTORY: /Users/adv/.rvm/gems/ruby-2.4.0
  - USER INSTALLATION DIRECTORY: /Users/adv/.gem/ruby/2.4.0
  - RUBY EXECUTABLE: /Users/adv/.rvm/rubies/ruby-2.4.0/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /Users/adv/.rvm/gems/ruby-2.4.0/bin
  - SPEC CACHE DIRECTORY: /Users/adv/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/adv/.rvm/rubies/ruby-2.4.0/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-16
  - GEM PATHS:
     - /Users/adv/.rvm/gems/ruby-2.4.0
     - /Users/adv/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/adv/.rvm/gems/ruby-2.4.0/bin
     - /Users/adv/.rvm/gems/ruby-2.4.0@global/bin
     - /Users/adv/.rvm/rubies/ruby-2.4.0/bin
     - /Users/adv/.fastlane/bin
     - /Library/Frameworks/Python.framework/Versions/3.7/bin
     - /usr/local/sbin
     - /Users/adv/.rbenv/shims
     - /Users/adv/.rvm/bin
     - /Users/adv/.fastlane/bin
     - /Library/Frameworks/Python.framework/Versions/3.7/bin
     - /usr/local/sbin
     - /Users/adv/.rbenv/shims
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/share/dotnet
     - /Library/Frameworks/Mono.framework/Versions/Current/Commands
     - /Users/adv/android-sdks/platform-tools
     - /Users/adv/android-sdks/tools
     - /opt/metasploit-framework/bin
     - /opt/metasploit-framework/bin
     - /Users/adv/android-sdks/platform-tools/
     - /Users/adv/android-sdks/tools/
     - /opt/metasploit-framework/bin
     - /opt/metasploit-framework/bin

which gem的输出:

/Users/adv/.rvm/rubies/ruby-2.4.0/bin/gem

rbenv versions的输出:

  system
* 2.4.1 (set by /Users/adv/.rbenv/version)

ruby -ropenssl -e "puts OpenSSL::OPENSSL_LIBRARY_VERSION"的输出:

OpenSSL 1.1.1b  26 Feb 2019

rvm list的输出:

=* ruby-2.4.0 [ x86_64 ]

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

UPDATE :完全删除rvmrbenv(并重新启动Terminal会话)后,我尝试再次执行gem update,这是结果:

$ gem update
Updating installed gems
Updating CFPropertyList
Fetching: CFPropertyList-3.0.0.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

我认为它现在再次使用了macOS的系统ruby。

以下是一些输出:

gem -v的输出:

  

2.5.2.3

ruby -v的输出:

  

红宝石2.3.7p456(2018-03-28修订版63024)[universal.x86_64-darwin18]

which gem的输出:

  

/ usr / bin / gem

which ruby的输出:

  

/ usr / bin / ruby​​

我的目标是毫无问题地使用gem(安装和更新等)。接下来我该怎么办?

1 个答案:

答案 0 :(得分:1)

def get_context_data(self, *args, **kwargs): context = super(PostFeed, self).get_context_data(**kwargs) context["posts"] = Post.objects.all() return context 出现在ruby 1.8.7中,mac os内置了2.3.7。

只需在10.14.2上进行检查-

OpenSSL::SSL::SSLContext#ssl_version=

即使在系统ruby上也可以正常工作,OpenSSL版本与您的相同。

唯一值得怀疑的是rbenv与rvm冲突,因为您已经安装了它们,这可能会使加载的库和ruby编译混乱。我建议完全删除其中之一(也不要忘记在此之后开始新的Shell会话)并重新安装损坏的红宝石。