新手问题 ERROR: While executing gem ... (Gem::Exception)

jsz_1000 · 2016年10月17日 · 最后由 jsz_1000 回复于 2016年10月18日 · 10349 次阅读
操作环境:mac 10.11.3;目的搭建gitlab 服务时,ruby安装遇到的奇葩问题如下:

Ruby Note: The current supported Ruby versions are 2.1.x and 2.3.x. 2.3.x is preferred, and support for 2.1.x will be dropped in the future.
The use of Ruby version managers such as RVM, rbenv or chruby with GitLab in production, frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH, and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby. Remove the old Ruby 1.8 if present:

sudo apt-get remove ruby1.8 Download Ruby and compile it:
mkdir /tmp/ruby && cd /tmp/ruby

curl --remote-name --progress https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.gz echo 'c39b4001f7acb4e334cb60a0f4df72d434bef711 ruby-2.3.1.tar.gz' | shasum -c - && tar xzf ruby-2.3.1.tar.gz
$ cd ruby-2.3.1
$ ./configure  --with-openssl-dir=/usr/local/ssl
$ make
$ sudo make install,
一、jddeiMac:~ iosTest$ sudo gem install bundler --no-ri --no-rdoc
Password:
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
二、jddeiMac:~ iosTest$ gem update 
Updating installed gems
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
jddeiMac:~ iosTest$ gem list

*** LOCAL GEMS ***
bigdecimal (1.2.8)
did_you_mean (1.0.0)
io-console (0.4.5)
json (1.8.3)
minitest (5.8.3)
net-telnet (0.1.1)
power_assert (0.2.6)
psych (2.0.17)
rake (10.4.2)
rdoc (4.2.1)
test-unit (3.1.5)
jddeiMac:~ iosTest$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15.3.0]
jddeiMac:~ iosTest$ gem --version
2.5.1
jddeiMac:~ iosTest$ openssl version
OpenSSL 0.9.8zg 14 July 2015

stackflow 上说修改为 🐷 ./configure --with-openssl-dir=/usr/local/bin 或者 ./configure --with-openssl-dir=/usr/local/ssl;🐷 此方法都尝试了失败

添加 淘宝源也失败;悲催
bash-3.2$ gem  sources
*** CURRENT SOURCES ***

http://rubygems.org/
bash-3.2$ gem sources -a https://ruby.taobao.org/
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
jddeiMac:~ iosTest$ gem env
/usr/local/lib/ruby/2.3.0/rubygems/commands/environment_command.rb:154: warning: Insecure world writable dir /Users/iosTest/apache-tomcat-7.0.28/bin in PATH, mode 040777
RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.1
  - RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15.3.0]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/iosTest/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/local/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /Users/iosTest/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/2.3.0
     - /Users/iosTest/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["https://ruby.taobao.org/"]
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://ruby.taobao.org/
  - SHELL PATH:
     - /usr/local/bin
     - /opt/local/bin
     - /opt/local/sbin
     - /Users/iosTest/.nvm/versions/node/v6.0.0/bin
     - /Users/iosTest/.opam/4.01.0/bin
     - /Library/Frameworks/Python.framework/Versions/3.4/bin
     - /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/git/bin
     - /Users/iosTest/apache-tomcat-7.0.28/bin
     - /Users/iosTest/Desktop/jinde/software/Mac/java/ant/apache-ant-1.9.4/bin
     - /Users/iosTest/Library/Android/sdk/platform-tools
     - /Users/iosTest/Library/Android/sdk/tools
     - /Users/iosTest/Desktop/jinde/software/Mac/IOS/smartmonkey/20150716/CrashMonkey4IOS/bin
     - /Users/iosTest/Desktop/jinde/software/Mac/IOS/crashmonkey/bin
     - /Users/iosTest/Desktop/inferConfig/infer/infer/bin

请大神们给点意见指点一下啊;👃 👃 👃 👃 👃 👃

相关链接:https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md

找到你的 openssl dir,如果是 homebrew brew info openssl

#1 楼 @flowerwrong

针对ruby小白的我茫然啊;
bash-3.2$ brew info openssl
openssl: stable 1.0.2j (bottled) [keg-only]
SSL/TLS cryptography library
https://openssl.org/
/usr/local/Cellar/openssl/1.0.2a-1 (1,633 files, 12.2M)
  Poured from bottle on 2015-04-27 at 15:37:46
/usr/local/Cellar/openssl/1.0.2e (1,646 files, 11.9M)
  Built from source on 2015-12-22 at 21:15:01
/usr/local/Cellar/openssl/1.0.2h_1 (1,691 files, 12M)
  Poured from bottle on 2016-10-11 at 12:54:35
/usr/local/Cellar/openssl/1.0.2j (1,695 files, 12M)
  Poured from bottle on 2016-10-14 at 17:15:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl.rb
==> Dependencies
Build: makedepend ✔
==> Options
--universal
    Build a universal binary
--without-test
    Skip build-time tests (not recommended)
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

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

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

恩啊,找到以后怎么处理啊?大神

./configure --with-openssl-dir=/usr/local/opt/openssl

这个坑是你没有用 rvm 安装 ruby 造成的,通过 rvm 安装他会自动帮你在编译的时候链接好 openssl、readlines 等依赖(如果没有会自动下载安装)

另外淘宝源的历史使命已经结束了,切换到 ruby-china 源

#3 楼 @flowerwrong 好的,非常感谢;我今天在尝试一下;

#5 楼 @jasl 好的,我在 Mac 系统上 安装 gitlab 时,在安装 ruby 提示,不建议要用 rvm 来管理 ruby;所有就没有用 rvm;

#6 楼 @jsz_1000 四楼建议更好。工欲善其事 必先利其器。这里有些软件推荐http://blog.liveneeq.com/tech/2016/02/21/mac-developer-softwares.html

#8 楼 @flowerwrong 好的;今天都去尝试一下;非常感谢

jsz_1000 关闭了讨论。 10月18日 11:14
jsz_1000 重新开启了讨论。 10月18日 11:14

#3 楼 @flowerwrong 感谢热心回复的朋友,问题已解决;

bash-3.2$./configure --with-openssl-dir=/usr/local/opt/openssl
bash-3.2$make
bash-3.2$make install 
bash-3.2$ gem source -a https://gems.ruby-china.org
https://gems.ruby-china.org added to sources
bash-3.2$ gem sources
*** CURRENT SOURCES ***

http://rubygems.org/
https://gems.ruby-china.org
bash-3.2$ gem sources -r http://rubygems.org/
http://rubygems.org/ removed from sources
bash-3.2$ gem sources
*** CURRENT SOURCES ***

https://gems.ruby-china.org
bash-3.2$  gem sources -u 
source cache successfully updated
jsz_1000 关闭了讨论。 10月18日 14:48
需要 登录 后方可回复, 如果你还没有账号请 注册新账号