繁体   English   中英

无法通过RVM安装Ruby 2.0.0

[英]Can't install Ruby 2.0.0 through RVM

我继承了一个遗留代码库,需要 Ruby 2.0.0 与 RVM 一起安装。 我在 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 <piotr.kuczynski@gmail.com>" [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/openssl@1.1/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/openssl@1.1/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/openssl@1.1/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,并尝试了数十种替代方法:没有一种有效。

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

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

Clang 现在在为 macOS 构建 C 或 Objective-C 代码(-Werror=implicit-function-declaration 标志打开)时使用没有明确声明的 function 时报告错误。 此额外的错误检测统一了 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/openssl@1.1/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\"

这已在 RVM 中修复。 采用

rvm get master

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM