Repository  -  API  -  Source


March 14, 2023


  • Add --with-magic-flags option for building libmagic.


January 23, 2023


  • Update to latest libmagic version (5.44).
  • Update mini_portile2 to version 2.8.0.
  • Update RDoc in the Ruby gemspec and the Rake task.
  • Update PKG_CONFIG_PATH paths to include more platforms.
  • Add new library flag called MAGIC_NO_COMPRESS_FORK.
  • Add assert to ensure that the internal object is initialised.
  • Reduce scope of some string variables.
  • Relax rake-compiler and rake-compiler-dock dependencies.
  • Only enable support for the GC compaction when there is platform support.
  • Remove workaround for linux build per RCD.
  • Work around Ruby 3.1 pkg_config limitations.


January 28, 2022


  • Added a pessimistic version pin of rake-compiler and rake-compiler-dock versions in Gemfile.


  • Removed RubyGems version pin from the Gem gemspec file.
  • Simplified the .gitlab-ci.yml used to run CI remotely on GitLab.
  • Enabled verbose log when cross-compiling a native Ruby Gem using the rake-compiler-dock Gem. This allows for commands run to be shown.


  • Retired support for Ruby version 2.5 as it has reached End of Life (EOL).


December 22, 2021


  • ext: load C extension files from non-native gems via "require"


November 20, 2021
  • No changes


November 20, 2021


  • Check for pkg-config when building static libraries.


September 30, 2021


  • Introduce support for building native gems.


  • Relax mini_portile2 dependency.
  • Use RB_ALLOC() over calling ruby_xmalloc() directly
  • Address warnings reported by cppcheck.
  • Address code style that script reported.
  • Fix how flags are set for the open() function.
  • Clean up type definitions.
  • Add alias Magic::mime_type for Magic::mime.
  • Make magic_set_flags() return void as its return value was never used.


  • Fix truffleruby test failure
  • Fix --use-system-libraries not working with Rake install


March 25, 2015


  • Added Gemnasium, plus Coveralls and Code Climate integration (and hence improved code test coverage).
  • Added functionality to handle releasing the GVL for any file and/or I/O operations.
  • Added ability to Magic#flags_array to return name of each flag that is set.
  • Added naïve synchronization via Mutex#lock and Mutex#unlock methods to make interactions with libmagic more thread-safe.
  • Added ability for Travis CI test against multiple versions of vanilla libmagic.
  • Added LLVM (clang) compiler to build with to Travis CI, and fixed various issues reported by clang compiler during build-time.
  • Added ability for Magic#load to take nil as valid argument.
  • Added support for the MAGIC_CONTINUE flag so that Magic#file, Magic#buffer and Magic#descriptor methods will return an array for multiple results when appropriate.
  • Added rudimentary Vagrantfile that can be used to build a development environment.
  • Added the Guard Ruby gem for convenience, with an appropriate Guardfile.


  • Re-factored the API and cleaned up small portions of code and documentation.
  • Changed Magic#version_array and Magic#version_string methods to be a singleton methods.
  • Renamed the Magic#flags_array method to Magic#flags_to_a.
  • Changed the Magic::new method, so that it accepts an array of paths from which to load the Magic database.
  • Moved integration with File and String core classes into separate namespace.
  • Changed the behavior not to catch the generic Magic::Error, plus always to raise on errors coming from libmagic. This is to make it more aligned with the standard library, where file and I/O related errors would raise an appropriate exception.
  • Changed behavior consistent among various versions of libmagic adhering to the POSIX standard. This concerns the following IEEE 1003.1 standards:


  • Fixed formatting and white spaces.
  • Fixed Travis CI build against Rubinius.
  • Fixed setting of global errno value to avoid race conditions.
  • Fixed issue with libmagic's regular expression (regex) library not working with UTF-8 (or any other wide-character encoding).
  • Fixed build to make it work with C++ compilers.
  • Fixed any C90 standard related build-time warnings.
  • Fixed version number to comply with Semantic Versioning 2 (


  • Retired support for Ruby 1.8.x (no support for MRI, Ruby Enterprise Edition and Rubinius).
  • Retired testing with Ruby 1.9.2 and 2.1.0, and added 2.2.0 on Travis CI.
  • Removed forward declaration of errno as it's not needed on systems with modern C/C++ libraries and compilers.
  • Removed the -Wl,--no-undefined option from LDFLAGS, as they might break on some systems.


March 21, 2014


  • First version of Magic.