ankane / or-tools-ruby

Operations research tools for Ruby
Apache License 2.0
179 stars 25 forks source link

Mac M1 (arm64) or-tools installation bug #29

Closed artur79 closed 2 years ago

artur79 commented 2 years ago

Not caused by this gem but maybe someone already solved it. I'v followed instructions for README and when bundling received an error:

Installing or-tools 0.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3/ext/or-tools
/Users/artur/.rbenv/versions/2.6.6/bin/ruby -I /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20220404-17366-xmbcyt.rb extconf.rb --with-or-tools-dir\=/opt/homebrew
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rice-4.0.3/lib/mkmf-rice.rb:16: warning: already initialized constant MakeMakefile::CONFTEST_C
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/mkmf.rb:259: warning: previous definition of CONFTEST_C was here
checking for rice/rice.hpp in /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rice-4.0.3/include... yes
checking for -lc++... yes
checking for -lstdc++... yes
checking for -lortools... yes
creating Makefile

current directory: /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3/ext/or-tools
make "DESTDIR=" clean

current directory: /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3/ext/or-tools
make "DESTDIR="
compiling ext.cpp
clang: warning: argument unused during compilation: '-diag-disable=175,188,2259' [-Wunused-command-line-argument]
warning: unknown warning option '-Wduplicated-cond' [-Wunknown-warning-option]
warning: unknown warning option '-Wrestrict' [-Wunknown-warning-option]
warning: unknown warning option '-Wimplicit-fallthrough=0'; did you mean '-Wimplicit-fallthrough'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-packed-bitfield-compat' [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=format'; did you mean '-Wproperty-attribute-mismatch'? [-Wunknown-warning-option]
warning: unknown warning option '-Wsuggest-attribute=noreturn' [-Wunknown-warning-option]
In file included from ext.cpp:4:
In file included from /opt/homebrew/include/ortools/constraint_solver/routing.h:179:
/opt/homebrew/include/ortools/base/map_util.h:173:1: error: 'auto' return without trailing return type; deduced return types are a C++14 extension
auto& InsertKeyOrDie(Collection* const collection,
^
/opt/homebrew/include/ortools/base/map_util.h:175:8: warning: decomposition declarations are a C++17 extension [-Wc++17-extensions]
  auto [it, did_insert] = collection->insert(typename Collection::value_type(
       ^~~~~~~~~~~~~~~~
In file included from ext.cpp:4:
In file included from /opt/homebrew/include/ortools/constraint_solver/routing.h:181:
In file included from /opt/homebrew/include/ortools/constraint_solver/constraint_solver.h:89:
In file included from /opt/homebrew/include/absl/random/random.h:40:
/opt/homebrew/include/absl/random/internal/randen_engine.h:70:3: warning: definition of implicit copy assignment operator for 'randen_engine<unsigned long long>' is deprecated because it has a user-declared copy
constructor [-Wdeprecated-copy]
  randen_engine(const randen_engine&) = default;
  ^
/opt/homebrew/include/absl/random/internal/nonsecure_base.h:53:61: note: in implicit copy assignment operator for 'absl::random_internal::randen_engine<unsigned long long>' first required here
  NonsecureURBGBase& operator=(NonsecureURBGBase&&) = default;
                                                            ^
/opt/homebrew/include/ortools/sat/util.h:97:20: note: in defaulted move assignment operator for 'absl::random_internal::NonsecureURBGBase<absl::random_internal::randen_engine<unsigned long long>>' first required
here
      absl_random_ = absl::BitGen(absl::SeedSeq({params.random_seed()}));
                   ^
In file included from ext.cpp:4:
In file included from /opt/homebrew/include/ortools/constraint_solver/routing.h:188:
In file included from /opt/homebrew/include/ortools/sat/theta_tree.h:21:
In file included from /opt/homebrew/include/ortools/sat/integer.h:42:
/opt/homebrew/include/ortools/sat/sat_solver.h:163:43: warning: loop variable 'p' creates a copy from type 'const std::pair<Literal, double>' [-Wrange-loop-construct]
    for (const std::pair<Literal, double> p : prefs) {
                                          ^
/opt/homebrew/include/ortools/sat/sat_solver.h:163:10: note: use reference type 'const std::pair<Literal, double> &' to prevent copying
    for (const std::pair<Literal, double> p : prefs) {
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                          &
ext.cpp:13:10: fatal error: 'rice/Array.hpp' file not found
#include <rice/Array.hpp>
         ^~~~~~~~~~~~~~~~
9 warnings and 2 errors generated.
make: *** [ext.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3 for inspection.
Results logged to /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-21/2.6.0/or-tools-0.3.3/gem_make.out

  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:99:in `run'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:51:in `block in make'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in `each'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in `make'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:62:in `block in build'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tempfile.rb:295:in `open'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in `build'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:185:in `block in build_extension'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:181:in `build_extension'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `each'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/installer.rb:830:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/source/rubygems.rb:200:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:59:in `block in install_with_settings'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_integration.rb:575:in `install_with_build_args'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:59:in `install_with_settings'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:62:in `apply_func'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:54:in `loop'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:54:in `process_queue'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing or-tools (0.3.3), and Bundler cannot continue.

In Gemfile:
  or-tools
artur79 commented 2 years ago

I think I overcome above error by setting:

bundle config build.or-tools --with-or-tools-dir=/opt/homebrew --with-cflags=CMAKE_CXX_STANDARD=14

I believe it's some c++ compilation setting, but got new error instead :)

Installing or-tools 0.3.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3/ext/or-tools
/Users/artur/.rbenv/versions/2.6.6/bin/ruby -I /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20220404-23424-ymp984.rb extconf.rb --with-or-tools-dir\=/opt/homebrew
--with-cflags\=CMAKE_CXX_STANDARD\=14
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rice-4.0.3/lib/mkmf-rice.rb:16: warning: already initialized constant MakeMakefile::CONFTEST_C
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/mkmf.rb:259: warning: previous definition of CONFTEST_C was here
checking for rice/rice.hpp in /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rice-4.0.3/include... no
*** 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
    --without-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/artur/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME)
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rice-4.0.3/lib/mkmf-rice.rb:120:in `<top (required)>': Could not find rice/rice.hpp header (RuntimeError)
    from /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
    from /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
    from /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
    from extconf.rb:1:in `<main>'
/Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mkmf-rice (LoadError)
    from /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from extconf.rb:1:in `<main>'

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

  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-21/2.6.0/or-tools-0.3.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/or-tools-0.3.3 for inspection.
Results logged to /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/extensions/-darwin-21/2.6.0/or-tools-0.3.3/gem_make.out

  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:99:in `run'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tempfile.rb:295:in `open'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in `build'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:185:in `block in build_extension'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:181:in `build_extension'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `each'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/2.6.0/rubygems/installer.rb:830:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/source/rubygems.rb:200:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:59:in `block in install_with_settings'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/rubygems_integration.rb:575:in `install_with_build_args'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:59:in `install_with_settings'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:62:in `apply_func'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:54:in `loop'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:54:in `process_queue'
  /Users/artur/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bundler-2.2.31/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing or-tools (0.3.3), and Bundler cannot continue.

In Gemfile:
  or-tools
ankane commented 2 years ago

Hey @artur79, it looks like you're using an older version of the gem (0.3.3). Make sure you have the latest OR-Tools from Homebrew (9.2) and try version 0.6.3 of the gem (the latest version is 0.7.0, but it requires OR-Tools 9.3, which isn't on Homebrew yet).

artur79 commented 2 years ago

@ankane works like a charm, thank you very much :) I think issue may be closed