【问题标题】:ruby 2.0 bz2 gem installation in MacPorts MacOS在 MacPorts MacOS 中安装 ruby​​ 2.0 bz2 gem
【发布时间】:2013-06-19 22:56:43
【问题描述】:

谁能提供有关如何在 MacPorts 环境中为 ruby​​-2.0 安装 bzip2-ruby 的指导?

当我安装它时,它抱怨没有找到 version.h。我做了一个 version.h 到 ruby​​-2.0.0/version.h 的符号链接,然后我得到了这些:

~ >$ sudo gem install bz2
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing bz2:
ERROR: Failed to build gem native extension.
    /opt/local/bin/ruby2.0 extconf.rb
checking for BZ2_bzWriteOpen() in -lbz2... yes
creating Makefile
make
compiling bz2.c
In file included from bz2.c:2:
/opt/local/include/ruby-2.0.0/ruby/backward/rubyio.h:2:2: warning: use "ruby/io.h" instead of "rubyio.h" [-W#warnings]
#warning use "ruby/io.h" instead of "rubyio.h"
 ^
bz2.c:85:19: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
    rb_raise(exc, msg);
                  ^~~
bz2.c:112:46: error: no member named 'len' in 'struct RArray'
    for (i = 0; i < RARRAY(bz_internal_ary)->len; i++) {
                    ~~~~~~~~~~~~~~~~~~~~~~~  ^
bz2.c:113:43: error: no member named 'ptr' in 'struct RArray'
        Data_Get_Struct(RARRAY(bz_internal_ary)->ptr[i], struct bz_iv, bziv);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-2.0.0/ruby/ruby.h:1026:17: note: expanded from macro 'Data_Get_Struct'
    Check_Type((obj), T_DATA); \
                ^
/opt/local/include/ruby-2.0.0/ruby/ruby.h:539:47: note: expanded from macro 'Check_Type'
#define Check_Type(v,t) rb_check_type((VALUE)(v),(t))
                                              ^
bz2.c:113:43: error: no member named 'ptr' in 'struct RArray'
        Data_Get_Struct(RARRAY(bz_internal_ary)->ptr[i], struct bz_iv, bziv);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/local/include/ruby-2.0.0/ruby/ruby.h:1027:30: note: expanded from macro 'Data_Get_Struct'
    (sval) = (type*)DATA_PTR(obj);\
                             ^
/opt/local/include/ruby-2.0.0/ruby/ruby.h:985:30: note: expanded from macro 'DATA_PTR'
#define DATA_PTR(dta) (RDATA(dta)->data)
                             ^
/opt/local/include/ruby-2.0.0/ruby/ruby.h:1103:37: note: expanded from macro 'RDATA'
#define RDATA(obj)   (R_CAST(RData)(obj))
                                    ^~~
bz2.c:116:29: error: use of undeclared identifier 'OpenFile'
                RFILE(bziv->io)->fptr == (OpenFile *)ptr) {
                                          ^
bz2.c:116:39: error: expected expression
                RFILE(bziv->io)->fptr == (OpenFile *)ptr) {
                                                    ^
bz2.c:218:46: error: no member named 'len' in 'struct RArray'
    for (i = 0; i < RARRAY(bz_internal_ary)->len; i++) {
                    ~~~~~~~~~~~~~~~~~~~~~~~  ^
bz2.c:219:34: error: no member named 'ptr' in 'struct RArray'
        elem = RARRAY(bz_internal_ary)->ptr[i];
               ~~~~~~~~~~~~~~~~~~~~~~~  ^
bz2.c:304:6: error: use of undeclared identifier 'OpenFile'
            OpenFile *file = (OpenFile *)ptr;
            ^
bz2.c:304:16: error: use of undeclared identifier 'file'
            OpenFile *file = (OpenFile *)ptr;
                      ^
bz2.c:304:24: error: use of undeclared identifier 'OpenFile'
            OpenFile *file = (OpenFile *)ptr;
                              ^
bz2.c:304:34: error: expected expression
            OpenFile *file = (OpenFile *)ptr;
                                        ^
bz2.c:305:10: error: use of undeclared identifier 'file'
            if (file->f) {
                ^
bz2.c:306:10: error: use of undeclared identifier 'file'
                fclose(file->f);
                       ^
bz2.c:307:3: error: use of undeclared identifier 'file'
                file->f = 0;
                ^
bz2.c:309:10: error: use of undeclared identifier 'file'
            if (file->f2) {
                ^
bz2.c:310:10: error: use of undeclared identifier 'file'
                fclose(file->f2);
                       ^
bz2.c:311:3: error: use of undeclared identifier 'file'
                file->f2 = 0;
                ^
bz2.c:399:23: error: no member named 'len' in 'struct RString'
    if (RSTRING(str)->len) {
        ~~~~~~~~~~~~  ^
bz2.c:400:32: error: no member named 'ptr' in 'struct RString'
        rb_str_cat(obj, RSTRING(str)->ptr, RSTRING(str)->len);
                        ~~~~~~~~~~~~  ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
make: *** [bz2.o] Error 1
Gem files will remain installed in /opt/local/lib/ruby2.0/gems/2.0.0/gems/bz2-0.2.2 for inspection.
Results logged to /opt/local/lib/ruby2.0/gems/2.0.0/gems/bz2-0.2.2/ext/bz2/gem_make.out

【问题讨论】:

  • 有人破解了 bzip2-ruby-rb20,因为原来的 bzip2-ruby 似乎不再被维护。不幸的是,替换宝石现在也不起作用(无论如何都不适合我)。最初的 gem 被描述为“非常 hacky”。 :(

标签: gem macports ruby-2.0 bzip2


【解决方案1】:

我不使用 MacPorts。对不起。

但是,如果您尝试在 MacOS 上更新您的 Ruby,并且仍然希望可以选择返回到以前的版本,我会在一篇博文(下面的链接)中详细说明,因为我想我会解释这一点或者在我用于测试的机器上再做一次。

Updating MacOS to Ruby 2.0

【讨论】:

  • 在您的答案中包含实际答案,而不是答案的链接。不鼓励使用一列式答案。
  • 嘿曼努埃尔,这是一个冗长的答案,需要一些解释,因此链接。如果我能在这里轻松回答,我会的。
  • Stackoverflow 可以处理长答案。如果由于过程困难而需要进行一些解释,如果您在回答中这样做,那就更受欢迎了。
猜你喜欢
  • 2013-03-17
  • 2013-10-24
  • 2014-01-24
  • 1970-01-01
  • 2021-11-15
  • 1970-01-01
  • 2013-07-10
  • 2023-04-01
  • 1970-01-01
相关资源
最近更新 更多