title: Error installing ruby file magic on OSX
body: <pre><code>Fetching ruby-filemagic 0.7.2
  Installing ruby-filemagic 0.7.2 with native extensions
  Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
  
      current directory: /Users/quantum/.rvm/gems/ruby-2.4.2/gems/ruby-filemagic-0.7.2/ext/filemagic
  /Users/quantum/.rvm/rubies/ruby-2.4.2/bin/ruby -r ./siteconf20180207-53723-1uirx0.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.
  
  have_library: checking for -lgnurx... -------------------- no
  
  "gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.4.2  -lpthread -lgmp -ldl -lobjc "
  ld: warning: directory not found for option '-L/opt/local/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/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.4.2 -lgnurx  -lpthread -lgmp -ldl -lobjc "
  ld: warning: directory not found for option '-L/opt/local/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 &gt; 1000000) {
   8:     printf("%p", &amp;t);
   9:   }
  10: 
  11:   return 0;
  12: }
  13: 
  14: int t(void) { ; return 0; }
  /* end */
  
  --------------------
  
  have_library: checking for magic_open() in -lmagic... -------------------- no
  
  "gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.4.2 -lmagic  -lpthread -lgmp -ldl -lobjc "
  conftest.c:13: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 &gt; 1000000) {
   8:     printf("%p", &amp;t);
   9:   }
  10: 
  11:   return 0;
  12: }
  13: int t(void) { void ((*volatile p)()); p = (void ((*)()))magic_open; return !p; }
  /* end */
  
  "gcc -o conftest -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/x86_64-darwin17 -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0/ruby/backward -I/Users/quantum/.rvm/rubies/ruby-2.4.2/include/ruby-2.4.0 -I. -I/opt/local/include -I/usr/local/include -I/usr/include  -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/Users/quantum/.rvm/rubies/ruby-2.4.2/lib -L/opt/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib     -lruby.2.4.2 -lmagic  -lpthread -lgmp -ldl -lobjc "
  ld: warning: directory not found for option '-L/opt/local/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 &gt; 1000000) {
   8:     printf("%p", &amp;t);
   9:   }
  10: 
  11:   return 0;
  12: }
  13: extern void magic_open();
  14: int t(void) { magic_open(); return 0; }
  /* end */
  
  --------------------
  </code></pre>
  
  <p>It looks like the <code>magic_open</code> is failing? How can I fix this?</p>