maybe icon indicating copy to clipboard operation
maybe copied to clipboard

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

Open detherminal opened this issue 6 months ago • 13 comments

I am getting the following error while running bundle install in Fedora 39. I have installed "Development Tools" and "Development Libraries" etc. Run with sudo because otherwise I get permission denied errors.

Sorry if it's an easy issue, I don't know ruby well.

Errors:

user@beast ~/m/a/m/maybe (main)> sudo bundle install
[sudo] password for user: 
Don't run Bundler as root. Installing your bundle as root will break this application for all
non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
Installing io-console 0.7.2 with native extensions
Installing websocket-driver 0.7.6 with native extensions
Installing better_html 2.0.2 with native extensions
Installing bcrypt 3.1.20 with native extensions
Installing msgpack 1.7.2 with native extensions
Installing nio4r 2.7.0 with native extensions
Installing pg 1.5.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/share/gems/gems/nio4r-2.7.0/ext/nio4r
/usr/bin/ruby -I/usr/share/rubygems extconf.rb
checking for unistd.h... *** 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=${opt-dir}/include
	--without-opt-include
	--with-opt-lib=${opt-dir}/lib64
	--without-opt-lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/$(RUBY_BASE_NAME)
	--with-unistd-dir
	--without-unistd-dir
	--with-unistd-include=${unistd-dir}/include
	--without-unistd-include
	--with-unistd-lib=${unistd-dir}/lib64
	--without-unistd-lib
/usr/share/ruby/mkmf.rb:480:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.

	from /usr/share/ruby/mkmf.rb:606:in `block in try_compile'
	from /usr/share/ruby/mkmf.rb:555:in `with_werror'
	from /usr/share/ruby/mkmf.rb:606:in `try_compile'
	from /usr/share/ruby/mkmf.rb:1151:in `block in have_header'
	from /usr/share/ruby/mkmf.rb:983:in `block in checking_for'
	from /usr/share/ruby/mkmf.rb:344:in `block (2 levels) in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:344:in `block in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:340:in `postpone'
	from /usr/share/ruby/mkmf.rb:982:in `checking_for'
	from /usr/share/ruby/mkmf.rb:1150:in `have_header'
	from extconf.rb:32:in `<main>'

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

  /usr/lib64/gems/ruby/nio4r-2.7.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/gems/gems/nio4r-2.7.0 for inspection.
Results logged to /usr/lib64/gems/ruby/nio4r-2.7.0/gem_make.out

  /usr/share/rubygems/rubygems/ext/builder.rb:119:in `run'
  /usr/share/rubygems/rubygems/ext/ext_conf_builder.rb:27:in `build'
  /usr/share/rubygems/rubygems/ext/builder.rb:187:in `build_extension'
  /usr/share/rubygems/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `each'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `build_extensions'
  /usr/share/rubygems/rubygems/installer.rb:843:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/source/rubygems.rb:205:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:132:in `do_install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:123:in `block in
worker_pool'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:62:in `apply_func'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:90:in `block (2 levels) in
create_threads'

An error occurred while installing nio4r (2.7.0), and Bundler cannot continue.

In Gemfile:
  hotwire-livereload was resolved to 1.3.1, which depends on
    actioncable was resolved to 7.2.0.alpha, which depends on
      nio4r


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/share/gems/gems/msgpack-1.7.2/ext/msgpack
/usr/bin/ruby -I/usr/share/rubygems extconf.rb
checking for rb_enc_interned_str() in ruby.h... *** 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=${opt-dir}/include
	--without-opt-include
	--with-opt-lib=${opt-dir}/lib64
	--without-opt-lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/$(RUBY_BASE_NAME)
/usr/share/ruby/mkmf.rb:480:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.

	from /usr/share/ruby/mkmf.rb:573:in `try_link0'
	from /usr/share/ruby/mkmf.rb:591:in `try_link'
	from /usr/share/ruby/mkmf.rb:802:in `try_func'
	from /usr/share/ruby/mkmf.rb:1110:in `block in have_func'
	from /usr/share/ruby/mkmf.rb:983:in `block in checking_for'
	from /usr/share/ruby/mkmf.rb:344:in `block (2 levels) in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:344:in `block in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:340:in `postpone'
	from /usr/share/ruby/mkmf.rb:982:in `checking_for'
	from /usr/share/ruby/mkmf.rb:1109:in `have_func'
	from extconf.rb:3:in `<main>'

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

  /usr/lib64/gems/ruby/msgpack-1.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/gems/gems/msgpack-1.7.2 for inspection.
Results logged to /usr/lib64/gems/ruby/msgpack-1.7.2/gem_make.out

  /usr/share/rubygems/rubygems/ext/builder.rb:119:in `run'
  /usr/share/rubygems/rubygems/ext/ext_conf_builder.rb:27:in `build'
  /usr/share/rubygems/rubygems/ext/builder.rb:187:in `build_extension'
  /usr/share/rubygems/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `each'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `build_extensions'
  /usr/share/rubygems/rubygems/installer.rb:843:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/source/rubygems.rb:205:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:132:in `do_install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:123:in `block in
worker_pool'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:62:in `apply_func'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:90:in `block (2 levels) in
create_threads'

An error occurred while installing msgpack (1.7.2), and Bundler cannot continue.

In Gemfile:
  bootsnap was resolved to 1.18.3, which depends on
    msgpack


Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/share/gems/gems/io-console-0.7.2/ext/io/console
/usr/bin/ruby -I/usr/share/rubygems extconf.rb
checking for rb_io_path()... *** 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=${opt-dir}/include
	--without-opt-include
	--with-opt-lib=${opt-dir}/lib64
	--without-opt-lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/usr/bin/$(RUBY_BASE_NAME)
/usr/share/ruby/mkmf.rb:480:in `try_do': The compiler failed to generate an executable file.
(RuntimeError)
You have to install development tools first.

	from /usr/share/ruby/mkmf.rb:573:in `try_link0'
	from /usr/share/ruby/mkmf.rb:591:in `try_link'
	from /usr/share/ruby/mkmf.rb:802:in `try_func'
	from /usr/share/ruby/mkmf.rb:1110:in `block in have_func'
	from /usr/share/ruby/mkmf.rb:983:in `block in checking_for'
	from /usr/share/ruby/mkmf.rb:344:in `block (2 levels) in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:344:in `block in postpone'
	from /usr/share/ruby/mkmf.rb:314:in `open'
	from /usr/share/ruby/mkmf.rb:340:in `postpone'
	from /usr/share/ruby/mkmf.rb:982:in `checking_for'
	from /usr/share/ruby/mkmf.rb:1109:in `have_func'
	from extconf.rb:4:in `<main>'

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

  /usr/lib64/gems/ruby/io-console-0.7.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/share/gems/gems/io-console-0.7.2 for inspection.
Results logged to /usr/lib64/gems/ruby/io-console-0.7.2/gem_make.out

  /usr/share/rubygems/rubygems/ext/builder.rb:119:in `run'
  /usr/share/rubygems/rubygems/ext/ext_conf_builder.rb:27:in `build'
  /usr/share/rubygems/rubygems/ext/builder.rb:187:in `build_extension'
  /usr/share/rubygems/rubygems/ext/builder.rb:221:in `block in build_extensions'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `each'
  /usr/share/rubygems/rubygems/ext/builder.rb:218:in `build_extensions'
  /usr/share/rubygems/rubygems/installer.rb:843:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/source/rubygems.rb:205:in `install'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:54:in `install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:132:in `do_install'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/installer/parallel_installer.rb:123:in `block in
worker_pool'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:62:in `apply_func'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:57:in `block in process_queue'
  <internal:kernel>:187:in `loop'
  /usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:54:in `process_queue'
/usr/share/gems/gems/bundler-2.5.5/lib/bundler/worker.rb:90:in `block (2 levels) in
create_threads'

An error occurred while installing io-console (0.7.2), and Bundler cannot continue.

In Gemfile:
  debug was resolved to 1.9.1, which depends on
    irb was resolved to 1.11.1, which depends on
      reline was resolved to 0.4.2, which depends on
        io-console

detherminal avatar Feb 06 '24 14:02 detherminal

Are you able to use the provided devcontainer? (should work out of the box with vscode and devcontainer extension)

robzolkos avatar Feb 06 '24 14:02 robzolkos

I deployed the devcontainer but I can't connect it via localhost:3000. It says The connection was reset in Firefox

detherminal avatar Feb 06 '24 15:02 detherminal

What about 127.0.0.1:3000 ?

robzolkos avatar Feb 06 '24 15:02 robzolkos

What about 127.0.0.1:3000 ?

Same result

detherminal avatar Feb 06 '24 15:02 detherminal

And you are using vscode to open the devcontainer? Once it is running what is the output of docker ps in your terminal?

robzolkos avatar Feb 06 '24 15:02 robzolkos

Yes, I am using VSCode to use devcontainer. The output of docker ps is this:

user@beast ~> docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS          PORTS                                       NAMES
2bdaa4f4af9c   maybe_devcontainer-app   "/bin/sh -c 'echo Co…"   30 minutes ago   Up 30 minutes   0.0.0.0:3000->3000/tcp, :::3000->3000/tcp   maybe_devcontainer-app-1
b1f8cd55b586   postgres:latest          "docker-entrypoint.s…"   30 minutes ago   Up 30 minutes   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp   maybe_devcontainer-db-1
6bbf188663f2   redis:latest             "docker-entrypoint.s…"   30 minutes ago   Up 30 minutes   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   maybe_devcontainer-redis-1

detherminal avatar Feb 06 '24 15:02 detherminal

and have you started the app inside the devcontainer bin/dev ?

robzolkos avatar Feb 06 '24 15:02 robzolkos

Yes, the output:

root@2bdaa4f4af9c:/workspace# bin/dev
15:58:50 web.1  | started with pid 9461
15:58:50 css.1  | started with pid 9462
15:58:51 web.1  | => Booting Puma
15:58:51 web.1  | => Rails 7.2.0.alpha application starting in development 
15:58:51 web.1  | => Run `bin/rails server --help` for more startup options
15:58:52 web.1  | Puma starting in single mode...
15:58:52 web.1  | * Puma version: 6.4.2 (ruby 3.3.0-p0) ("The Eagle of Durango")
15:58:52 web.1  | *  Min threads: 3
15:58:52 web.1  | *  Max threads: 3
15:58:52 web.1  | *  Environment: development
15:58:52 web.1  | *          PID: 9461
15:58:52 web.1  | * Listening on http://127.0.0.1:3000
15:58:52 web.1  | Use Ctrl-C to stop
15:58:52 css.1  | 
15:58:52 css.1  | Rebuilding...
15:58:53 css.1  | 
15:58:53 css.1  | Done in 468ms.

detherminal avatar Feb 06 '24 16:02 detherminal

ok and this is on your local computer right? not a server out on the internet somewhere. Remember that currently the app is not production ready. For local development only.

robzolkos avatar Feb 06 '24 16:02 robzolkos

Yes, fully local. I have tried to make everything as described in the both README and your instructions.

detherminal avatar Feb 06 '24 16:02 detherminal

ok thanks for trying. I'll look into this in more detail after work - I have a fedora machine I can test this on. In the meantime, a couple of things to try...see if it connects on http://host.docker.internal:3000/ and also if there are any log output at all.

robzolkos avatar Feb 06 '24 16:02 robzolkos

Also try updating the line in Procfile.dev to web: bin/rails server -b 0.0.0.0 and see if that works

robzolkos avatar Feb 06 '24 16:02 robzolkos

@detherminal we've added some updated guides to getting the project setup. You can find the one for Linux here - https://github.com/maybe-finance/maybe/wiki/Linux-Dev-Setup-Guide which has several "troubleshooting" tips.

Can you go through the guide and let me know if/where you run into issues?

zachgoll avatar Feb 13 '24 02:02 zachgoll

Going to close out for now. If you need additional help getting setup, Discord is a good spot for that:

https://link.maybe.co/discord

zachgoll avatar Feb 14 '24 12:02 zachgoll