ruby-on-rails - 无法在 mac m1 big sur 上安装 ruby​​-filemagic 0.7.2

标签 ruby-on-rails ruby

安装 ruby​​-filemagic 0.7.2 失败 我正在使用 mac M1 Bigsur ver 11.5.2

我已经尝试过的:

brew 安装 libmagic

已经安装但是仍然安装ruby-filemagic失败

这是日志:

    current directory: /Users/<username>/.rvm/gems/ruby-2.6.5/gems/ruby-filemagic-0.7.2/ext/filemagic
/Users/<username>/.rvm/rubies/ruby-2.6.5/bin/ruby -I /Users/<username>/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210907-83349-1lgxyp3.rb extconf.rb
checking for -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/<username>/.rvm/rubies/ruby-2.6.5/bin/$(RUBY_BASE_NAME)
    --with-magic-dir
    --without-magic-dir
    --with-magic-include
    --without-magic-include=${magic-dir}/include
    --with-magic-lib
    --without-magic-lib=${magic-dir}/lib
    --with-gnurx-dir
    --without-gnurx-dir
    --with-gnurx-include
    --without-gnurx-include=${gnurx-dir}/include
    --with-gnurx-lib
    --without-gnurx-lib=${gnurx-dir}/lib
    --with-gnurxlib
    --without-gnurxlib
    --with-magiclib
    --without-magiclib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/<username>/.rvm/gems/ruby-2.6.5/extensions/-darwin-20/2.6.0/ruby-filemagic-0.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/<username>/.rvm/gems/ruby-2.6.5/gems/ruby-filemagic-0.7.2 for inspection.
Results logged to /Users/<username>/.rvm/gems/ruby-2.6.5/extensions/-darwin-20/2.6.0/ruby-filemagic-0.7.2/gem_make.out

An error occurred while installing ruby-filemagic (0.7.2), and Bundler cannot continue.
Make sure that `gem install ruby-filemagic -v '0.7.2' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  ruby-filemagic

日志来自:/Users//.rvm/gems/ruby-2.6.5/extensions/-darwin-20/2.6.0/ruby-filemagic-0.7.2/mkmf.log

have_library: checking for -lgnurx... -------------------- no

"gcc -o conftest -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/-darwin20 -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/ruby/backward -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wno-error=implicit-function-declaration -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/<username>/.rvm/rubies/ruby-2.6.5/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib     -lruby.2.6   "
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib/'
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -o conftest -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/-darwin20 -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/ruby/backward -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wno-error=implicit-function-declaration -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/<username>/.rvm/rubies/ruby-2.6.5/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib     -lruby.2.6 -lgnurx   "
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib/'
ld: library not found for -lgnurx
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11: 
12:   return 0;
13: }
14: 
15: int t(void) { ; return 0; }
/* end */

--------------------

have_library: checking for magic_open() in -lmagic... -------------------- no

"gcc -o conftest -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/-darwin20 -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/ruby/backward -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wno-error=implicit-function-declaration -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/<username>/.rvm/rubies/ruby-2.6.5/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib     -lruby.2.6 -lmagic   "
conftest.c:14:57: error: use of undeclared identifier 'magic_open'
int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return !p; }
                                                        ^
1 error generated.
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11: 
12:   return 0;
13: }
14: int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return !p; }
/* end */

"gcc -o conftest -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/-darwin20 -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/ruby/backward -I/Users/<username>/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/libksba/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/zlib/include -I/opt/homebrew/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wno-error=implicit-function-declaration -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/<username>/.rvm/rubies/ruby-2.6.5/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib -L. -fstack-protector-strong -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/libksba/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/openssl@1.1/lib     -lruby.2.6 -lmagic   "
ld: warning: directory not found for option '-L/opt/local/lib'
ld: warning: directory not found for option '-L/usr/local/opt/openssl/lib/'
ld: library not found for -lmagic
clang: error: linker command failed with exit code 1 (use -v to see invocation)
checked program was:
/* begin */
 1: #include "ruby.h"
 2: 
 3: /*top*/
 4: extern int t(void);
 5: int main(int argc, char **argv)
 6: {
 7:   if (argc > 1000000) {
 8:     int (* volatile tp)(void)=(int (*)(void))&t;
 9:     printf("%d", (*tp)());
10:   }
11: 
12:   return 0;
13: }
14: extern void magic_open();
15: int t(void) { magic_open(); return 0; }
/* end */

--------------------

谁能帮帮我,我被困在这个... *注意--- 作为我以前使用 rbenv 的信息,它是否可能导致冲突或其他什么?现在我使用 rmv

最佳答案

我遇到了同样的问题。我可以使用 a comment on a gist 中的以下命令安装它

gem install ruby​​-filemagic -v '0.7.2' --source 'https://rubygems.org/' --with-magic-include=/opt/homebrew/include --with -magic-lib=/opt/homebrew/lib/

还有其他questions包括 --with-magic-include=/opt/homebrew/include --with-magic-lib=/opt/homebrew/lib/

如果没有 --source 'https://rubygems.org/' 标志,它就无法工作。

关于ruby-on-rails - 无法在 mac m1 big sur 上安装 ruby​​-filemagic 0.7.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69083813/

相关文章:

html - rails form_tag _path 参数

Ruby/Cucumber - 'puts' 引起麻烦

ruby-on-rails - 在 Rails 中更高效地查找或创建多条记录

ruby-on-rails - rails : Multiple "types" of one model through related models?

ruby-on-rails - 使用 Rails 和 Devise 的 STI

Ruby:嵌套的 if 语句

ruby - 如何跨同一模块的类访问类实例变量?

ruby-on-rails - rails 和重构,针对 vim 用户的建议工具和技术?

php - 将 PHP 代码转换为 Ruby 以获得 SHA512 哈希码

ruby - 为什么 2 个相同的字符串在 Ruby 中具有相同的 object_id?