### ImageMagick version

6.9.13-4

### Operating system

MacOS

### Operating system, version and so on

14.2.1

### Description

I saw post like [this][1] and tried advice there but problem still exists so posting here again. Thanks in advance!

when I run `DEPENDENCIES_NEXT=0 bundle install` I got following error:

```
Can't install RMagick 2.16.0. Can't find MagickWand.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
    --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/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/bin/$(RUBY_BASE_NAME)

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

  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/extensions/-darwin-22/2.6.0/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/extensions/-darwin-22/2.6.0/rmagick-2.16.0/gem_make.out

  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:99:in `run'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tempfile.rb:295:in `open'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in `build'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:185:in `block in build_extension'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:181:in `build_extension'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:226:in `each'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:226:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/installer.rb:833:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in `do_install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in `block in worker_pool'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in `apply_func'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `loop'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `process_queue'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing rmagick (2.16.0), and Bundler cannot continue.

In Gemfile:
  gruff was resolved to 0.7.0, which depends on
    rmagick
```

I tried reinstall and relink image, and those were executed successfully:

```
yyyyyyyyy@bcd074b3401b xxxxxx % brew unlink imagemagick@6
Unlinking /opt/homebrew/Cellar/imagemagick@6/6.9.13-4... 0 symlinks removed.
yyyyyyyyy@bcd074b3401b xxxxxx % brew link --force imagemagick@6

Linking /opt/homebrew/Cellar/imagemagick@6/6.9.13-4... 76 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/imagemagick@6/bin:$PATH"' >> ~/.zshrc

``` 

`gem install rmagick` installed `rmagick-5.3.0` successfully but which doesn't help.

I think the root cause is that somehow gem's installation is default for `rmagick-5.3.0`, and when I try to install 2.16.0, I saw exact same error message of bundle. gem's version is 3.0.9
 
For this project I need to use ruby 2.6.6 and I also encountered another problem while installing bundler:

```
bundler -v 
Bundler version 2.4.22
```
`mdfind MagickWand.h` find nothing:

```/Users/xxxxx/Library/Application Support/Sublime Text/Local/Auto Save Session.sublime_session```

  [1]: https://stackoverflow.com/questions/39699325/an-error-occurred-while-installing-rmagick-2-16-0-i-tried-all-option-provided

### Steps to Reproduce

`DEPENDENCIES_NEXT=0 bundle install` or gem install rmagick -v '2.16.0', they return same error

### Images

_No response_
An error occurred while running bundle install or gem install rmagick -v '2.16.0'
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : An error occurred while running bundle install or gem install rmagick -v '2.16.0'
Issue date:

--- start body ---
### ImageMagick version

6.9.13-4

### Operating system

MacOS

### Operating system, version and so on

14.2.1

### Description

I saw post like [this][1] and tried advice there but problem still exists so posting here again. Thanks in advance!

when I run `DEPENDENCIES_NEXT=0 bundle install` I got following error:

```
Can't install RMagick 2.16.0. Can't find MagickWand.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
    --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/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/bin/$(RUBY_BASE_NAME)

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

  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/extensions/-darwin-22/2.6.0/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/rmagick-2.16.0 for inspection.
Results logged to /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/extensions/-darwin-22/2.6.0/rmagick-2.16.0/gem_make.out

  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:99:in `run'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/tempfile.rb:295:in `open'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in `build'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:185:in `block in build_extension'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:181:in `build_extension'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:226:in `each'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/ext/builder.rb:226:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/rubies/ruby-2.6.6/lib/ruby/site_ruby/2.6.0/rubygems/installer.rb:833:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/source/rubygems.rb:203:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:130:in `do_install'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/installer/parallel_installer.rb:121:in `block in worker_pool'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:62:in `apply_func'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:57:in `block in process_queue'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `loop'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:54:in `process_queue'
  /Users/xxxxxxxxxxxx/.rvm/gems/ruby-2.6.6@yyyyyyyyy/gems/bundler-2.4.22/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'

An error occurred while installing rmagick (2.16.0), and Bundler cannot continue.

In Gemfile:
  gruff was resolved to 0.7.0, which depends on
    rmagick
```

I tried reinstall and relink image, and those were executed successfully:

```
yyyyyyyyy@bcd074b3401b xxxxxx % brew unlink imagemagick@6
Unlinking /opt/homebrew/Cellar/imagemagick@6/6.9.13-4... 0 symlinks removed.
yyyyyyyyy@bcd074b3401b xxxxxx % brew link --force imagemagick@6

Linking /opt/homebrew/Cellar/imagemagick@6/6.9.13-4... 76 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/imagemagick@6/bin:$PATH"' >> ~/.zshrc

``` 

`gem install rmagick` installed `rmagick-5.3.0` successfully but which doesn't help.

I think the root cause is that somehow gem's installation is default for `rmagick-5.3.0`, and when I try to install 2.16.0, I saw exact same error message of bundle. gem's version is 3.0.9
 
For this project I need to use ruby 2.6.6 and I also encountered another problem while installing bundler:

```
bundler -v 
Bundler version 2.4.22
```
`mdfind MagickWand.h` find nothing:

```/Users/xxxxx/Library/Application Support/Sublime Text/Local/Auto Save Session.sublime_session```

  [1]: https://stackoverflow.com/questions/39699325/an-error-occurred-while-installing-rmagick-2-16-0-i-tried-all-option-provided

### Steps to Reproduce

`DEPENDENCIES_NEXT=0 bundle install` or gem install rmagick -v '2.16.0', they return same error

### Images

_No response_
--- end body ---
