mimemagicrb / mimemagic

Mime type detection in ruby via file extension or file content
https://github.com/mimemagicrb/mimemagic
MIT License
419 stars 444 forks source link

An error occurred while installing mimemagic (0.3.10), and Bundler cannot continue. #162

Open anupamkakade opened 3 years ago

anupamkakade commented 3 years ago
An error occurred while installing mimemagic (0.3.10), and Bundler cannot continue.
Make sure that `gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  rails was resolved to 6.1.3, which depends on
    actionmailbox was resolved to 6.1.3, which depends on
      activestorage was resolved to 6.1.3, which depends on
        marcel was resolved to 0.3.3, which depends on
          mimemagic

Anybody seeing this issue ? Can you help me fix this. This issue is occurring after I installed ruby 3.0.1 via rvm

jgengo commented 3 years ago

@anupamkakade Do you have more logs below or it's all you received?!

carlosgomez2 commented 3 years ago

Same problem here, seems to be related to Apple M1 chipset, doing:

$ gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/' ERROR: Error installing mimemagic: ERROR: Failed to build gem native extension. ... checking host system type... Invalid configuration arm64-apple-darwin20': machinearm64-apple' not recognized configure: error: /bin/sh ./config.sub arm64-apple-darwin20 failed

carlosgomez2 commented 3 years ago

Perhaps I was wrong, sorry my first day in a mac environment, I just do brew install shared-mime-info and again try to install with gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/', then it just run fine.

log for reference.

`current directory: /Users/rasalghul/.gem/gems/mimemagic-0.4.3/ext/mimemagic /Users/rasalghul/.rbenv/versions/2.6.5/bin/ruby -rrubygems /Users/rasalghul/.gem/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/rasalghul/.gem/extensions/-darwin-20/2.6.0/mimemagic-0.4.3 RUBYLIBDIR\=/Users/rasalghul/.gem/extensions/-darwin-20/2.6.0/mimemagic-0.4.3 Ignoring nio4r-2.5.7 because its extensions are not built. Try: gem pristine nio4r --version 2.5.7 rake aborted! Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml", "/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/opt/local/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]

Ensure you have either installed the shared-mime-info package for your distribution, or obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file. /Users/rasalghul/.gem/gems/mimemagic-0.4.3/ext/mimemagic/Rakefile:15:in locate_mime_database' /Users/rasalghul/.gem/gems/mimemagic-0.4.3/ext/mimemagic/Rakefile:26:inblock in <top (required)>' /Users/rasalghul/.gem/gems/rake-13.0.3/exe/rake:27:in `

' Tasks: TOP => default (See full trace by running task with --trace)

rake failed, exit code 1`

yevhene commented 3 years ago

UPD: issue disappeared when I unset bundle path to vendor/bundle.

Same here. Ruby 3.0.1 (via rvm), Linux, Ubuntu 20.04.2 LTS. shared-mime-info is installed.

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

current directory:
/home/user/work/myproj/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic
/home/user/.rvm/rubies/ruby-3.0.1/bin/ruby -I/home/user/.rvm/rubies/ruby-3.0.1/lib/ruby/3.0.0
-rrubygems /home/user/work/myproj/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake
RUBYARCHDIR\=/home/user/work/myproj/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10
RUBYLIBDIR\=/home/user/work/myproj/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10
rake aborted!
ArgumentError: wrong number of arguments (given 2, expected 1)
/home/user/work/myproj/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:43:in
`block in <top (required)>'
/home/user/work/myproj/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake:27:in
`<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in
/home/user/work/myproj/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10 for inspection.
Results logged to
/home/user/work/myproj/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10/gem_make.out

An error occurred while installing mimemagic (0.3.10), and Bundler cannot continue.
Make sure that `gem install mimemagic -v '0.3.10'` succeeds before bundling.
atsheehan commented 3 years ago

I ran into this issue as well and was able to resolve it by upgrading rake to v13.

I could reproduce the issue with the following Gemfile:

source 'https://rubygems.org'

gem 'rake', '~> 12.3'
gem 'rails', '6.1.0'

When I ran bundle with the --path argument, I got the following error:

$ bundle install --path=vendor/bundle
...
Installing mimemagic 0.3.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: $DIR/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic
$HOME/.rbenv/versions/3.0.0/bin/ruby -I$HOME/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -rrubygems $DIR/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake
RUBYARCHDIR\=$DIR/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10 RUBYLIBDIR\=$DIR/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10
rake aborted!
ArgumentError: wrong number of arguments (given 2, expected 1)
$DIR/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:43:in `block in <top (required)>'
$DIR/vendor/bundle/ruby/3.0.0/gems/rake-12.3.3/exe/rake:27:in `<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in $DIR/vendor/bundle/ruby/3.0.0/gems/mimemagic-0.3.10 for inspection.
Results logged to $DIR/vendor/bundle/ruby/3.0.0/extensions/x86_64-linux/3.0.0/mimemagic-0.3.10/gem_make.out

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

In Gemfile:
  rails was resolved to 6.1.0, which depends on
    actionmailbox was resolved to 6.1.0, which depends on
      activestorage was resolved to 6.1.0, which depends on
        marcel was resolved to 0.3.3, which depends on
          mimemagic

Removing the rake ~> 12.3 restriction upgraded it to 13 and it worked after that.

ChrisBAshton commented 2 years ago

I ran brew install shared-mime-info but mimemagic still couldn't find it because Homebrew installed it in a different place to what was expected. I had to run:

cp /opt/homebrew/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml /opt/homebrew/share/mime/packages/

Then the bundle install worked 👍

clebio commented 2 years ago

The trace shows


Ensure you have either installed the shared-mime-info package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
of that file.

So, as an alternative to the previous comment here, you can export FREEDESKTOP_MIME_TYPES_PATH=$(brew --prefix)/Cellar/shared-mime-info/2.1/share/shared-mime-info/packages/freedesktop.org.xml

loqman commented 1 year ago

Ruby 3.2.2 Rails 6.1.7.6

Downgraded mimemagic to 0.3.8 and the issue was fixed.

gem 'mimemagic', '0.3.8'
baston1 commented 9 months ago

I had the same issue, I have the following in my project:

scaustin34 commented 7 months ago

I had the same issue, I have the following in my project:

  • Ruby 2.7.1
  • Rails 6.0.4
  • MacBook Pro Apple M3 with macOs Sonoma 14.3 I fixed with brew install shared-mime-info and then bundle install

This worked for me with Ruby 2.6.3, Rails 5.2.4, M3 14.4.1