无法通过RVM安装Ruby 2.0.0

问题描述 投票:0回答:3

我继承了一个遗留代码库,需要使用 RVM 安装 Ruby 2.0.0。我使用的是 Mac OS X Catalina,Ruby 2.0.0 的安装程序根本不起作用。

这是我的安装尝试,从安装 RVM 本身到尝试安装 Ruby 2.0.0。

nbyrd$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.10.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc
gpg: Signature made Wed Mar 25 14:58:42 2020 PDT
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D  6956 105B D0E7 3949 9BDB
GPG verified '/Users/nbyrd/.rvm/archives/rvm-1.29.10.tgz'
Installing RVM to /Users/nbyrd/.rvm/
    RVM PATH line found in /Users/nbyrd/.mkshrc.
    RVM PATH line not found for Bash or Zsh, rerun this command with '--auto-dotfiles' flag to fix it.
    RVM sourcing line found in /Users/nbyrd/.profile /Users/nbyrd/.bash_profile /Users/nbyrd/.zlogin.
Installation of RVM in /Users/nbyrd/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/nbyrd/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.

👉  Donate: https://opencollective.com/rvm/donate


nbyrd$ source ~/.profile
nbyrd$ rvm autolibs enable
nbyrd$ rvm install 2.0.0 --force
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.0.0-p648.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Installing requirements for osx.
Updating system.......
Installing required packages: openssl.
Updating certificates bundle '/usr/local/etc/[email protected]/cert.pem'
Requirements installation successful.
Installing Ruby from source to: /Users/nbyrd/.rvm/rubies/ruby-2.0.0-p648, this may take a while depending on your cpu(s)...
ruby-2.0.0-p648 - #downloading ruby-2.0.0-p648, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 10.2M  100 10.2M    0     0  18.2M      0 --:--:-- --:--:-- --:--:-- 18.2M
ruby-2.0.0-p648 - #extracting ruby-2.0.0-p648 to /Users/nbyrd/.rvm/src/ruby-2.0.0-p648.....
ruby-2.0.0-p648 - #applying patch /Users/nbyrd/.rvm/patches/ruby/2.0.0/openssl3.patch.
ruby-2.0.0-p648 - #applying patch /Users/nbyrd/.rvm/patches/ruby/2.0.0/update-autoconf.patch.
ruby-2.0.0-p648 - #configuring.................................................
ruby-2.0.0-p648 - #post-configuration.
ruby-2.0.0-p648 - #compiling......................
Error running '__rvm_make -j8',
please read /Users/nbyrd/.rvm/log/1605305278_ruby-2.0.0-p648/make.log

There has been an error while running make. Halting the installation.

这是错误消息中引用的“make.log”文件的内容:

[2020-11-13 14:09:14] __rvm_make
__rvm_make () 
{ 
    \make "$@" || return $?
}
current path: /Users/nbyrd/.rvm/src/ruby-2.0.0-p648
PATH=/usr/local/opt/coreutils/bin:/usr/local/opt/pkg-config/bin:/usr/local/opt/libtool/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/usr/local/sbin:/Users/nbyrd/.yarn/bin:/Users/nbyrd/.config/yarn/global/node_modules/.bin:/Users/nbyrd/.nvm/versions/node/v10.15.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/nbyrd/.rvm/bin
command(2): __rvm_make -j8
++ make -j8
    CC = /usr/bin/clang
    LD = ld
    LDSHARED = /usr/bin/clang -dynamiclib
    CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration   -fno-common -pipe 
    XCFLAGS = -include ruby/config.h -include ruby/missing.h -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS = -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/[email protected]/include   -I. -I.ext/include/x86_64-darwin19.6.0 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/[email protected]/lib  -install_name /Users/nbyrd/.rvm/rubies/ruby-2.0.0-p648/lib/libruby.2.0.0.dylib -current_version 2.0.0 -compatibility_version 2.0.0  -fstack-protector -Wl,-u,_objc_msgSend  -fstack-protector -Wl,-u,_objc_msgSend  
    SOLIBS = 
compiling main.c
compiling dmydln.c
compiling dmyencoding.c
compiling version.c
compiling miniprelude.c
translating probes probes.d
compiling bignum.c
compiling class.c
. ./vm_opts.h
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling enum.c
complex.c:79:1: warning: unused function 'f_cmp' [-Wunused-function]
f_cmp(VALUE x, VALUE y)
^
complex.c:109:1: warning: unused function 'f_lt_p' [-Wunused-function]
f_lt_p(VALUE x, VALUE y)
^
complex.c:116:1: warning: unused function 'f_mod' [-Wunused-function]
binop(mod, '%')
^
complex.c:30:21: note: expanded from macro 'binop'
inline static VALUE \
                    ^
<scratch space>:89:1: note: expanded from here
f_mod
^
complex.c:155:1: warning: unused function 'f_abs2' [-Wunused-function]
fun1(abs2)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:92:1: note: expanded from here
f_abs2
^
complex.c:157:1: warning: unused function 'f_conj' [-Wunused-function]
fun1(conj)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:96:1: note: expanded from here
f_conj
^
complex.c:159:1: warning: unused function 'f_floor' [-Wunused-function]
fun1(floor)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:100:1: note: expanded from here
f_floor
^
complex.c:160:1: warning: unused function 'f_imag' [-Wunused-function]
fun1(imag)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:102:1: note: expanded from here
f_imag
^
complex.c:164:1: warning: unused function 'f_real' [-Wunused-function]
fun1(real)
^
complex.c:37:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:110:1: note: expanded from here
f_real
^
complex.c:185:1: warning: unused function 'f_divmod' [-Wunused-function]
fun2(divmod)
^
complex.c:44:21: note: expanded from macro 'fun2'
inline static VALUE \
                    ^
<scratch space>:118:1: note: expanded from here
f_divmod
^
complex.c:197:1: warning: unused function 'f_idiv' [-Wunused-function]
fun2(idiv)
^
complex.c:44:21: note: expanded from macro 'fun2'
inline static VALUE \
                    ^
<scratch space>:124:1: note: expanded from here
f_idiv
^
complex.c:263:1: warning: unused function 'k_integer_p' [-Wunused-function]
k_integer_p(VALUE x)
^
complex.c:465:1: warning: unused function 'f_complex_new1' [-Wunused-function]
f_complex_new1(VALUE klass, VALUE x)
^
complex.c:547:1: warning: unused function 'm_sqrt_bang' [-Wunused-function]
imp1(sqrt)
^
complex.c:518:21: note: expanded from macro 'imp1'
inline static VALUE \
                    ^
<scratch space>:150:1: note: expanded from here
m_sqrt_bang
^
bignum.c:910:1: warning: unused function 'next_pow2' [-Wunused-function]
next_pow2(register unsigned long x)
^
compiling enumerator.c
compiling error.c
compiling eval.c
compiling load.c
compiling proc.c
compiling file.c
compiling gc.c
13 warnings generated.
compiling hash.c
compiling inits.c
compiling io.c
compiling marshal.c
compiling math.c
compiling node.c
compiling numeric.c
compiling object.c
compiling pack.c
compiling parse.c
compiling process.c
compiling random.c
compiling range.c
compiling rational.c
rational.c:86:1: warning: unused function 'f_gt_p' [-Wunused-function]
f_gt_p(VALUE x, VALUE y)
^
rational.c:136:1: warning: unused function 'f_floor' [-Wunused-function]
fun1(floor)
^
rational.c:40:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:93:1: note: expanded from here
f_floor
^
rational.c:157:1: warning: unused function 'f_truncate' [-Wunused-function]
fun1(truncate)
^
rational.c:40:21: note: expanded from macro 'fun1'
inline static VALUE \
                    ^
<scratch space>:103:1: note: expanded from here
f_truncate
^
rational.c:428:1: warning: unused function 'f_rational_new_bang2' [-Wunused-function]
f_rational_new_bang2(VALUE klass, VALUE x, VALUE y)
^
rational.c:537:1: warning: unused function 'f_rational_new1' [-Wunused-function]
f_rational_new1(VALUE klass, VALUE x)
^
rational.c:552:1: warning: unused function 'f_rational_new_no_reduce1' [-Wunused-function]
f_rational_new_no_reduce1(VALUE klass, VALUE x)
^
1 warning generated.
compiling re.c
compiling regcomp.c
compiling regenc.c
compiling regerror.c
compiling regexec.c
compiling regparse.c
compiling regsyntax.c
compiling ruby.c
6 warnings generated.
compiling safe.c
compiling signal.c
compiling sprintf.c
compiling st.c
compiling strftime.c
compiling string.c
compiling struct.c
compiling time.c
compiling transcode.c
compiling util.c
compiling variable.c
compiling compile.c
compiling debug.c
compiling iseq.c
compiling vm.c
compiling vm_dump.c
compiling vm_backtrace.c
compiling vm_trace.c
compiling thread.c
vm.c:1916:31: warning: expression does not compute the number of elements in this array; element type is 'int', not 'VALUE' (aka 'unsigned long') [-Wsizeof-array-div]
                                 sizeof(th->machine_regs) / sizeof(VALUE));
                                        ~~~~~~~~~~~~~~~~  ^
vm.c:1916:31: note: place parentheses around the 'sizeof(VALUE)' expression to silence this warning
thread.c:977:27: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
        tp->tv_usec = ts.tv_nsec / 1000;
                    ~ ~~~~~~~~~~~^~~~~~
thread.c:4835:20: error: implicit declaration of function 'rb_frame_last_func' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    const ID mid = rb_frame_last_func();
                   ^
thread.c:4835:20: note: did you mean 'rb_frame_this_func'?
./include/ruby/intern.h:369:4: note: 'rb_frame_this_func' declared here
ID rb_frame_this_func(void);
   ^
1 warning and 1 error generated.
make: *** [thread.o] Error 1
make: *** Waiting for unfinished jobs....
1 warning generated.
++ return 2

我真的不知道我能做些什么来克服这个错误。我以前从未使用过 Ruby,但看起来它的源代码中有一个函数调用,但没有函数声明(“rb_frame_last_func”)。

我尝试了多种 C 编译器,但没有一个能工作。我也尝试向 RVM 开发人员寻求帮助,但他们根本没有回答我的问题。 RVM 的网站没有有关这些错误的详细信息。我浏览了 Stackoverflow 和 Google,并尝试了数十种替代方法:但没有一个有效。

有人可以告诉我我在这里缺少什么吗?

ruby rvm
3个回答
5
投票

这是由于 Xcode 12 中包含的工具的行为发生了变化:

在为 macOS 构建 C 或 Objective-C 代码时,如果您使用没有显式声明的函数,Clang 现在会报告错误(-Werror=implicit-function-declaration 标志已打开)。这种额外的错误检测统一了 Clang 针对 iOS/tvOS 和 macOS 64 位目标的诊断行为。 (49917738)

https://developer.apple.com/documentation/xcode-release-notes/xcode-12-release-notes

您可能希望通过在您的环境中设置编译标志来将它们传递给RVM:

export optflags="-Wno-error=implicit-function-declaration"

然后您可以重试:

$ rvm install 2.0.0
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.15/x86_64/ruby-2.0.0-p648.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Warning: Calling `brew list` to only list formulae is deprecated! Use `brew list --formula` instead.
Installing requirements for osx.
Updating system - please wait
Installing required packages: openssl - please wait
Certificates bundle '/usr/local/etc/[email protected]/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/foo/.rvm/rubies/ruby-2.0.0-p648, this may take a while depending on your cpu(s)...
ruby-2.0.0-p648 - #downloading ruby-2.0.0-p648, this may take a while depending on your connection...
ruby-2.0.0-p648 - #extracting ruby-2.0.0-p648 to /Users/foo/.rvm/src/ruby-2.0.0-p648 - please wait
ruby-2.0.0-p648 - #applying patch /Users/foo/.rvm/patches/ruby/2.0.0/openssl3.patch - please wait
ruby-2.0.0-p648 - #applying patch /Users/foo/.rvm/patches/ruby/2.0.0/update-autoconf.patch - please wait
ruby-2.0.0-p648 - #configuring - please wait
ruby-2.0.0-p648 - #post-configuration - please wait
ruby-2.0.0-p648 - #compiling - please wait
ruby-2.0.0-p648 - #installing - please wait
ruby-2.0.0-p648 - #making binaries executable - please wait
ruby-2.0.0-p648 - #downloading rubygems-3.0.8
ruby-2.0.0-p648 - #extracting rubygems-3.0.8 - please wait
ruby-2.0.0-p648 - #removing old rubygems - please wait
ruby-2.0.0-p648 - #installing rubygems-3.0.8 - please wait
Error running 'env GEM_HOME=/Users/foo/.rvm/gems/ruby-2.0.0-p648@global GEM_PATH= /Users/foo/.rvm/rubies/ruby-2.0.0-p648/bin/ruby -d /Users/foo/.rvm/src/rubygems-3.0.8/setup.rb --no-document',
please read /Users/foo/.rvm/log/1605308161_ruby-2.0.0-p648/rubygems.install.log

尽管最后出现错误,Ruby 确实成功编译并安装了:

$ rvm list
   ruby-2.0.0-p648 [ x86_64 ]
   ruby-2.5.7 [ x86_64 ]
=* ruby-2.7.1 [ x86_64 ]
   ruby-3.0.0-preview1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default
$ rvm use 2.0.0
rvm use 2.0.0
Using /Users/foo/.rvm/gems/ruby-2.0.0-p648
YAML safe loading is not available. Please upgrade psych to a version that supports safe loading (>= 2.0).
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin19.6.0]

具有本机扩展的 gem 可能需要相同的修复:

gem install some_gem_name --with-cflags="-Wno-error=implicit-function-declaration"

或者对于使用捆绑器的应用程序:

bundle config build.some_gem_name --with-cflags=\"-Wno-error=implicit-function-declaration\"

3
投票

此问题已在 RVM 中修复。使用

rvm get master

要获取最新版本的 rvm 并再次运行 rvm install。

这是来源:https://github.com/rvm/rvm/pull/4995


0
投票

我在本地(在 MacOS Sonoma - 14.x 中,在基于 x86_64 的机器上,使用 XCode Tools 15.x)进行了一些工作和一些提示/帮助,来自 https://github.com/rbenv/ruby-构建/讨论/1883.

在这种情况下,我还必须维护一个使用 Ruby 2.1.9 的古老(且气隙)系统。

问题之一是 2.4.x 之前的 Ruby(我认为)不能与 Openssl 1.1 或更高版本一起使用。 MacOS 现在附带 OpenSSL 3.x 或更高版本(实际上是 LibreSSL 3.x)。一般来说,流程是

  1. 将 openssl 1.0.x 库安装到侧面位置
  2. 编译 Ruby 时使用适当的标志和库路径(在我的例子中为 2.1.9)
  3. 针对您的 Ruby 版本使用适当版本的 rubygems_update 和捆绑器。

我需要以下工具:

  • XCode CLI 工具 - 您可以通过
    xcode-select --install
  • 获取它们
  • rvm
    - 请参阅 https://rvm.io/ 了解有关如何获取它的更多详细信息。
  • homebrew
    - 有关如何获取它的更多详细信息,请参阅 https://brew.sh/
    • 我还需要
      gpg
      工具(导入
      rvm
      gpg 密钥)。通过
      brew install gpg
      为我安装。

基本上,我必须通过聪明(或不那么聪明)的技巧来安装旧版本的 openssl:

$ brew install rbenv/tap/[email protected]
$ CFLAGS="-Wno-error=implicit-function-declaration" rvm install 2.1.9 --with-openssl-dir=/usr/local/opt/[email protected]
$ gem update --system 2.7.10
$ gem install bundler --version 1.17.3
$ bundle install

由于我需要 Ruby 2.1.9,因此我必须将 rubygems_update 限制为 < 3.0 and bundler to < 2.0.

© www.soinside.com 2019 - 2024. All rights reserved.