Download & Extend

Fileinfo could not load the magic file on localhost for Windows 7, using XAMPP

Project:MimeDetect
Version:6.x-1.3
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:mime type, settings.php

Issue Summary

Hi. I use FileField 5.x-2.3-rc3 with MimeDetect 5.x-1.0-beta on my web hosting:

- PHP Version 5.2.4
- System FreeBSD 6.2-STABLE

I have this error on Status Report page

finfo_open() [<a href='function.finfo-open'>function.finfo-open</a>]: Failed to load magic database at '/home/html/enigmaczech.cz/public_html/sites/all/modules/content/mimedetect/magic'.

with red message

Mime Detection PHP FileInfo Extension
FileInfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.

I test finfo_open() function in misc path but for me work only this variant finfo_open(FILEINFO_MIME) (without second parameter). Maybe we need test this and on this case use finfo_open() without second parameter.

Comments

#1

Status:active» postponed (maintainer needs more info)

No, I specifically want to use the magic distributed with mime detect. I'll try to gain access to a freebsd machine to test out the magic installation on it. Can you try rebuilding the magic database to see if a local rebuild based on the distributed magic will work? I may need to have mime detect build the magic database from source if this proves to be a common portability problem.

#2

Status:postponed (maintainer needs more info)» closed (won't fix)

I try compile magic.mgc from magic file provide in MimeDetect 5.x-1.0-beta and i give many errors. I use command file -C -m magic and i give:

fem7# file -C -m magic
magic, 3003: Warning type `search/1     \0\0\0\0pwV1    Cracklib password index, big endian ("64-bit")' invalid
magic, 4002: Warning type `medate       x               Previous dump %s,' invalid
magic, 4003: Warning type `medate       x               This dump %s,' invalid
magic, 5262: Warning type `leqldate     x               last written at %s,' invalid
magic, 5265: Warning type `lequad               x               number of blocks %lld,' invalid
magic, 5266: Warning type `lequad               x               number of data blocks %lld,' invalid
magic, 5272: Warning type `lequad               x               pending blocks to free %lld,' invalid
magic, 5274: Warning type `lequad               x               system-wide uuid %0llx,' invalid
...

And finally:

fem7# file -v
file-4.12
magic file from /usr/share/misc/magic

I think on FreeBSD 6.2 is older version file library which not support some new magic file syntax. I have installed FreeBSD 7 on another machine and on this machine i compile provided magic file without problems.

#3

I have exactly the same problem. My server is FreeBSD also. I dont have the option for installing another version. Do I have a choice of using FileField with mimedetect or not?
thanks

#4

On my site i replace line 36 in mimedetect.module:

<?php
   
if (!$finfo = @finfo_open(FILEINFO_MIME, drupal_get_path('module', 'mimedetect') . '/magic')) {
?>

into

<?php
   
if (!$finfo = @finfo_open(FILEINFO_MIME)) {
?>

but this only remove error report in site status page...

#5

I've just encountered this problem on a FreeBSD 6.3 box. All of the proposed patches and fixes don't seem to work. The one patch I found seemed to apply to the installation script, not the module code. It's all rather confusing.

Can you briefly explain how the MimeDetect module installs its own magic files?

My system has them at /usr/share/misc/magic ... magic.mgc ... magic.mime ... magic.mime.mgc

The files in this directory are smaller than those in the mimedetect directory.

Should I be pointing fileinfo to the mimedetect directory or is the mimedetect module supposed to install them in the system directory? If the latter, is it ok to overwrite what's there?

There was mention of recompiling or reinstalling the magic file; how do I do this?

I am using KDE3.5.8 via PCBSD, so apparently other programs in KDE use the magic files that were already there. I obviously don't want to muck that up in the process.

Where do the magic files come from? If they need to be updated periodically, it would be nice to know how.

Thanks in advance, Jeff

#6

Title:finfo_open() error - Failed to load magic database...» Same issue... Fileinfo could not load the magic file.... under Ubuntu
Version:5.x-1.0-beta» 6.x-1.2
Category:feature request» support request
Status:closed (won't fix)» needs review

I have the same status page red box error: "Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module."

I replaced the magic.* files in /usr/share/file with those provided in the module and now sitting in /public_html/sites/all/modules/mimedetect, simply renaming the original files to magic_orig.*; however, there was not magic.mime.mgc so I left the orig one as it was.

I then rebooted the server. Is it necessary to recompile Magic?... How?

The server is running:
* Ubuntu 8.04.2
* Apache 2.2.11 Running
* PHP Version 5.2.9
* MySQL 5.0.67 Running
* Java: j2re1.4

#7

Title:Same issue... Fileinfo could not load the magic file.... under Ubuntu» Same issue... Fileinfo could not load the magic file....

I managed to solve this on my windows box running wampserver2 by replacing the magic files provided with mimedetect with the attached files (per some thread I found on a php forum). I spent quite a bit of time trying to fix this and this was the only way I could find. Everything seems to be functioning ok.

AttachmentSize
mimdetect_magic.zip 261.86 KB

#8

Bonjour.

is there another solution? I am hosted on Hostingrails.com (beginner plan, a shared server, Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/1.8 mod_bwlimited/1.4 PHP/5.2.3 SVN/1.5.0 Phusion_Passenger/2.1.3).
I have installed the mimedetect 6.x-1.2. I have seen there is another dev version. What about it ?

#9

Status:needs review» closed (duplicate)

#306217: Fileinfo could not load the magic file will allow people to configure their own path.

#10

I’ve just had the same problem.

Here’s how I corrected it in my case :

I edited the magic file that comes with mimedetect because, under Ubuntu, the file -C -m magic command gave me these lines :

magic, 2170: Warning: <= not supported
magic, 2910: Warning: description `Clarion Personal/Professional Developer (v2 and above) data fil' truncated
magic, 2921: Warning: description `Clarion Personal/Professional Developer (v2 and above) memo dat' truncated
magic, 2927: Warning: description `Clarion Personal/Professional Developer (v2 and above) help dat' truncated
magic, 5854: Warning: <= not supported
magic, 5857: Warning: <= not supported
magic, 7791: Warning: >= not supported
magic, 8599: Warning: escaped tab found, use \t instead

Here’s how I edited the above lines :
2170 → replace <= by < and add 1 to the following number (less than or equal to is not understood but less than is understood)
2910 → replace "v2 and above" by "v2+" (line is apparently too long)
2921 → replace "v2 and above" by "v2+" (line is apparently too long)
2927 → replace "v2 and above" by "v2+" (line is apparently too long)
5854 → replace <= by < and add 1 to the following number (less than or equal to is not understood but less than is understood)
5857 → replace <= by < and add 1 to the following number
7791 → replace >= by > and subtract 1 to the following number (0x200 → 0x1FF)
8599 → replace tabulation character right after \ by a the t letter (tabulation character is forbidden)

After these modifications, file -C -m magic works without any error message and generates the magic.mgc file.

Copying magic and magic.mgc back to the server (Debian with PHP 5.2.6-1+lenny3) does wonder as it is automatically recognized when you go under admin/report/status.

The only trouble that may happen from now on : an update of mimedetect and the old file coming back.

I’ve attached my modified magic if it can helps someone.

AttachmentSize
magic.gz 130.97 KB

#11

#7 doesn't help here ..
#10 does !!

#12

Status:closed (duplicate)» fixed

#10 worked like a charm thanks a lot zigazou !!

Server: Ubuntu 10.04 LTS x64 server, Php 5.3.2, Drupal 6.16

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

Version:6.x-1.2» 6.x-1.x-dev
Status:closed (fixed)» needs review

The patch in #10 works but this has not been merged into 6.x-1.x-dev.

#15

Getting "Fileinfo could not load the magic file". Running Drupal 6.17 on Ubuntu 10.04 LTS

#16

#10 worked like a charm for me too, thanx zigazou !

#17

Hi,

I too was having problems with the FileInfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module. error message using Windows. I managed to fix the problem by downloading the Windows Package from Sourceforge.

Installation:

1. Add php_fileinfo.dll to the list of enabled extensions in your php.ini file:
extension=php_fileinfo.dll, or uncomment it if its commented. You will need to restart apache after making changes to the php.ini file.

2. Download GNU file package for windows:
http://gnuwin32.sourceforge.net/downlinks/file-bin-zip.php

3. Extract the folder Share/File from the zip file. This folder contains 2 files, magic and magic.mgc.

4. Copy these files to your mimedetect folder, such as sites/all/modules/mimedetect, overwriting the original files.

5. Re-activate the module and it should work.

All the best,

Shane.

#18

Status:needs review» fixed

Well if you read the README or followed the issue referred in #9 you would have found that you can quite easily fix this by adding:

<?php
   $conf
['mimedetect_magic'] = '/usr/share/file/magic.mgc'; // For Debian based systems (includes Ubuntu).
?>

to the settings.php file.

Why go through all the pains of editing a gigantic file that will get clobbered in a module upgrade?

Marking this fixed.

#19

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#20

Category:support request» feature request
Status:closed (fixed)» active

Hi,

I found these warnings quite accidentally when reviewing my webserver's error.log:

# tail -f /var/log/apache2/error.log
file: File 4.26 supports only 6 version magic files. `sites/all/modules/mimedetect/magic.mgc' is version 4
sites/all/modules/mimedetect/magic, 2170: Warning: <= not supported
sites/all/modules/mimedetect/magic, 2910: Warning: description `Clarion Personal/Professional Developer (v2 and above) data fil' truncated
sites/all/modules/mimedetect/magic, 2921: Warning: description `Clarion Personal/Professional Developer (v2 and above) memo dat' truncated
sites/all/modules/mimedetect/magic, 2927: Warning: description `Clarion Personal/Professional Developer (v2 and above) help dat' truncated
sites/all/modules/mimedetect/magic, 5854: Warning: <= not supported
sites/all/modules/mimedetect/magic, 5857: Warning: <= not supported
sites/all/modules/mimedetect/magic, 7791: Warning: >= not supported
file: File 4.26 supports only 6 version magic files. `sites/all/modules/mimedetect/magic.mgc' is version 4

I hope that #18 fixes the issue for me, but I would like to change this report into a feature request:

Please check if the module and its requirements are fully operational and report back at ./admin/reports/status

This status overview is intended for such notifications, and it would be really helpful if it'd be used!

Thank you, -asb

#21

Had this issue too on Amazon's new Amazon Linux AMI. Posting in case others eventually have this issue.

The following worked for me:

Add the following to settings.php:

<?php
   $conf
['mimedetect_magic'] = '/usr/share/file/magic.mgc';
?>

The magic file is located in /usr/share/misc/magic and magic.mgc is at /usr/share/misc/magic.mgc

There was a symbolic link for magic in /usr/share/file/ but not for magic.mgc. I added that symbolic link, re-enabled the module and it worked!

#22

Title:Same issue... Fileinfo could not load the magic file.... » Fileinfo could not load the magic file on localhost for Windows 7, using XAMPP
Version:6.x-1.x-dev» 6.x-1.3
Category:feature request» support request

I'm new to Drupal, and I have spent hours with this issue looking for a solution. It just can't be this tough of an issue. The path on my machine is:

c:\XAMPP\htdocs\drupal\sites\all\modules\mimedetect
I keep seeing references to UNIX/LINUX paths, but nothing referring to Windows, other than the post above. I downloaded and replaced the 2 files from sourceforge, replaced them and restarted Apache and mysql, and then the drupal admin.

I haven't run into ANY issues with any other module I downloaded. This is getting quite frustrating. Any help greatly appreciated.

#23

well , its very sipmle r_darling
for windows and xampp all you have to do is
open settings.php under your default folder by sites.
make sure is writeable.
then you have to add the following at the end:

$conf = array(
'mimedetect_magic' => 'location',
);
so in your case:

$conf = array(
'mimedetect_magic' => 'c:\XAMPP\htdocs\drupal\sites\all\modules\mimedetect',
);

restart apache server: enable module ; and whow! : it works.

#24

for unix issues #21 jcarlson34's help worked nicely. thanx

#25

#10 Worked for me

#26

As it seems there is no fielinfo lib installed on the server i have to sue, I added following line to settings.php and giot rid of the error:
$conf['mimedetect_magic'] = '';

Not sure, it seems the lib provided by the module itself will be used in this case.

#27

#26 Worked here. #21 and similar did not work.

I'm running D7 on Centos 5.

file-4.17
magic file from /usr/share/file/magic

This magic file does not work, giving this error.

D6 on Centos 4

file-4.10
magic file from /usr/share/file/magic

Works without modification of settings.ini.

#28

Error message on a Debian "Lenny" server: FileInfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.

Magic file exists in usual location:

# ls -lah /usr/share/file/
insgesamt 1,8M
drwxr-xr-x   3 root root 4,0K 30. Dez 2010  .
drwxr-xr-x 128 root root 4,0K 13. Okt 01:14 ..
drwxr-xr-x   2 root root 4,0K  5. Aug 2010  magic
-rw-r--r--   1 root root 1,8M  5. Aug 2010  magic.mgc

My ./sites/default/settings.php include this line:

// For Debian based systems (includes Ubuntu)
$conf['mimedetect_magic'] = '/usr/share/file/magic.mgc';

This kept me scratching my head, until I remembered that this was a i18n site and I was also running different configurations at ./sites/*/settings.php. I added the $conf variable to the other configs, the the error was gone. So double check which settings.php you are actually using ;)

#29

Running CentOS 5, PHP 5.3.8 and #10 worked for me! Thanks zigazou!

nobody click here