photostructure / exiftool-vendored.js

Fast, cross-platform Node.js access to ExifTool
https://photostructure.github.io/exiftool-vendored.js/
MIT License
405 stars 37 forks source link

problem with ignoreShebang #163

Closed aztech55 closed 6 months ago

aztech55 commented 6 months ago

Describe the bug Hello! I am using home-gallery which depends on exiftools-vendored. I belive that ignoreShebang property when set to true is not working as it should.

To Reproduce

  1. /usr/bin/perl must not exist
  2. Using this test, we should get: exiftools object, exiftools version or rejection error.
ExifTool = require("exiftool-vendored").ExifTool;
exiftool = new ExifTool({ taskTimeoutMillis: 5000 }); 
console.log(exiftool);
exiftool.version().then(ver => { 
        console.log(`*****VERSION: ${ver}`); 
        exiftool.end();
    }, rej => { 
        console.log(`*****REJECT: ${rej}`);
     }).catch(err => console.log(`***** CATCH: ${err}`));
root@MyCloudEX2Ultra home-gallery # node -e 'ExifTool = require("exiftool-vendored").ExifTool;     exiftool = new ExifTool({ taskTimeoutMillis: 5000 });      console.log(exiftool);     exiftool.version().then(ve
r => {              console.log(`*****VERSION: ${ver}`);              exiftool.end();         }, rej => {              console.log(`*****REJECT: ${rej}`);          }).catch(err => console.log(`***** CATCH: ${err
}`));'
ExifTool {
  on: [Function (anonymous)],
  options: {
    maxProcs: 1,
    maxProcAgeMillis: 300000,
    onIdleIntervalMillis: 2000,
    maxReasonableProcessFailuresPerMinute: 10,
    spawnTimeoutMillis: 30000,
    minDelayBetweenSpawnMillis: 1500,
    taskTimeoutMillis: 5000,
    maxTasksPerProcess: 500,
    endGracefulWaitTimeMillis: 500,
    streamFlushMillis: 30,
    cleanupChildProcs: true,
    maxIdleMsPerProcess: 0,
    maxFailedTasksPerProcess: 2,
    healthCheckIntervalMillis: 30000,
    pidCheckIntervalMillis: 120000,
    logger: [Function: logger],
    taskRetries: 1,
    exiftoolPath: '/mnt/HD/HD_a2/Nas_Prog/entware/home/home-gallery/node_modules/exiftool-vendored.pl/bin/exiftool',
    exiftoolArgs: [ '-stay_open', 'True', '-@', '-' ],
    exiftoolEnv: {},
    checkPerl: true,
    pass: '{ready}',
    fail: '{ready}',
    exitCommand: '-stay_open\nFalse\n',
    versionCommand: '-ver\n-ignoreMinorErrors\n-execute\n',
    healthCheckCommand: '-ver\n-execute\n',
    backfillTimezones: true,
    defaultVideosToUTC: true,
    geoTz: [Function: geoTz],
    ignoreZeroZeroLatLon: true,
    imageHashType: false,
    includeImageDataMD5: undefined,
    inferTimezoneFromDatestamps: false,
    inferTimezoneFromDatestampTags: [
      'SubSecDateTimeOriginal',
      'SubSecCreateDate',
      'SubSecMediaCreateDate',
      'DateTimeOriginal',
      'CreateDate',
      'MediaCreateDate',
      'CreationDate',
      'DateTimeCreated',
      'TimeCreated'
    ],
    numericTags: [
      '*Duration*',
      'GPSAltitude',
      'GPSLatitude',
      'GPSLongitude',
      'GPSPosition',
      'Orientation'
    ],
    useMWG: false,
    ignoreShebang: true,
    processFactory: [Function: processFactory]
  },
  batchCluster: BatchCluster {
    emitter: EventEmitter {
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false
    },
    on: [Function: bound addListener],
    off: [Function: bound removeListener],
    options: {
      maxProcs: 1,
      maxProcAgeMillis: 300000,
      onIdleIntervalMillis: 2000,
      maxReasonableProcessFailuresPerMinute: 10,
      spawnTimeoutMillis: 30000,
      minDelayBetweenSpawnMillis: 1500,
      taskTimeoutMillis: 5000,
      maxTasksPerProcess: 500,
      endGracefulWaitTimeMillis: 500,
      streamFlushMillis: 30,
      cleanupChildProcs: true,
      maxIdleMsPerProcess: 0,
      maxFailedTasksPerProcess: 2,
      healthCheckIntervalMillis: 30000,
      pidCheckIntervalMillis: 120000,
      logger: [Function: logger],
      taskRetries: 1,
      exiftoolPath: '/mnt/HD/HD_a2/Nas_Prog/entware/home/home-gallery/node_modules/exiftool-vendored.pl/bin/exiftool',
      exiftoolArgs: [Array],
      exiftoolEnv: {},
      checkPerl: true,
      pass: '{ready}',
      fail: '{ready}',
      exitCommand: '-stay_open\nFalse\n',
      versionCommand: '-ver\n-ignoreMinorErrors\n-execute\n',
      healthCheckCommand: '-ver\n-execute\n',
      backfillTimezones: true,
      defaultVideosToUTC: true,
      geoTz: [Function: geoTz],
      ignoreZeroZeroLatLon: true,
      imageHashType: false,
      includeImageDataMD5: undefined,
      inferTimezoneFromDatestamps: false,
      inferTimezoneFromDatestampTags: [Array],
      numericTags: [Array],
      useMWG: false,
      ignoreShebang: true,
      processFactory: [Function: processFactory],
      observer: [EventEmitter],
      passRE: /(?:\n|^)\{ready\}(?:\r?\n|$)/,
      failRE: /(?:\n|^)\{ready\}(?:\r?\n|$)/
    }
  }
}
root@MyCloudEX2Ultra home-gallery #

We can observe that:

As a workaround, i have created a symlink from my actual perl path: /opt/bin/perl -> /usr/bin/perl.

root@MyCloudEX2Ultra home-gallery # ln -s /opt/bin/perl /usr/bin/perl
root@MyCloudEX2Ultra home-gallery # node -e 'ExifTool = require("exiftool-vendored").ExifTool;     exiftool = new ExifTool({ taskTimeoutMillis: 5000 });      console.log(exiftool);     exiftool.version().then(ve
r => {              console.log(`*****VERSION: ${ver}`);              exiftool.end();         }, rej => {              console.log(`*****REJECT: ${rej}`);          }).catch(err => console.log(`***** CATCH: ${err
}`));'
ExifTool {
  on: [Function (anonymous)],
  options: {
    maxProcs: 1,
    maxProcAgeMillis: 300000,
    onIdleIntervalMillis: 2000,
    maxReasonableProcessFailuresPerMinute: 10,
    spawnTimeoutMillis: 30000,
    minDelayBetweenSpawnMillis: 1500,
    taskTimeoutMillis: 5000,
    maxTasksPerProcess: 500,
    endGracefulWaitTimeMillis: 500,
    streamFlushMillis: 30,
    cleanupChildProcs: true,
    maxIdleMsPerProcess: 0,
    maxFailedTasksPerProcess: 2,
    healthCheckIntervalMillis: 30000,
    pidCheckIntervalMillis: 120000,
    logger: [Function: logger],
    taskRetries: 1,
    exiftoolPath: '/mnt/HD/HD_a2/Nas_Prog/entware/home/home-gallery/node_modules/exiftool-vendored.pl/bin/exiftool',
    exiftoolArgs: [ '-stay_open', 'True', '-@', '-' ],
    exiftoolEnv: {},
    checkPerl: true,
    pass: '{ready}',
    fail: '{ready}',
    exitCommand: '-stay_open\nFalse\n',
    versionCommand: '-ver\n-ignoreMinorErrors\n-execute\n',
    healthCheckCommand: '-ver\n-execute\n',
    backfillTimezones: true,
    defaultVideosToUTC: true,
    geoTz: [Function: geoTz],
    ignoreZeroZeroLatLon: true,
    imageHashType: false,
    includeImageDataMD5: undefined,
    inferTimezoneFromDatestamps: false,
    inferTimezoneFromDatestampTags: [
      'SubSecDateTimeOriginal',
      'SubSecCreateDate',
      'SubSecMediaCreateDate',
      'DateTimeOriginal',
      'CreateDate',
      'MediaCreateDate',
      'CreationDate',
      'DateTimeCreated',
      'TimeCreated'
    ],
    numericTags: [
      '*Duration*',
      'GPSAltitude',
      'GPSLatitude',
      'GPSLongitude',
      'GPSPosition',
      'Orientation'
    ],
    useMWG: false,
    ignoreShebang: false,
    processFactory: [Function: processFactory]
  },
  batchCluster: BatchCluster {
    emitter: EventEmitter {
      _events: [Object: null prototype],
      _eventsCount: 4,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false
    },
    on: [Function: bound addListener],
    off: [Function: bound removeListener],
    options: {
      maxProcs: 1,
      maxProcAgeMillis: 300000,
      onIdleIntervalMillis: 2000,
      maxReasonableProcessFailuresPerMinute: 10,
      spawnTimeoutMillis: 30000,
      minDelayBetweenSpawnMillis: 1500,
      taskTimeoutMillis: 5000,
      maxTasksPerProcess: 500,
      endGracefulWaitTimeMillis: 500,
      streamFlushMillis: 30,
      cleanupChildProcs: true,
      maxIdleMsPerProcess: 0,
      maxFailedTasksPerProcess: 2,
      healthCheckIntervalMillis: 30000,
      pidCheckIntervalMillis: 120000,
      logger: [Function: logger],
      taskRetries: 1,
      exiftoolPath: '/mnt/HD/HD_a2/Nas_Prog/entware/home/home-gallery/node_modules/exiftool-vendored.pl/bin/exiftool',
      exiftoolArgs: [Array],
      exiftoolEnv: {},
      checkPerl: true,
      pass: '{ready}',
      fail: '{ready}',
      exitCommand: '-stay_open\nFalse\n',
      versionCommand: '-ver\n-ignoreMinorErrors\n-execute\n',
      healthCheckCommand: '-ver\n-execute\n',
      backfillTimezones: true,
      defaultVideosToUTC: true,
      geoTz: [Function: geoTz],
      ignoreZeroZeroLatLon: true,
      imageHashType: false,
      includeImageDataMD5: undefined,
      inferTimezoneFromDatestamps: false,
      inferTimezoneFromDatestampTags: [Array],
      numericTags: [Array],
      useMWG: false,
      ignoreShebang: false,
      processFactory: [Function: processFactory],
      observer: [EventEmitter],
      passRE: /(?:\n|^)\{ready\}(?:\r?\n|$)/,
      failRE: /(?:\n|^)\{ready\}(?:\r?\n|$)/
    }
  }
}
*****VERSION: 12.70
root@MyCloudEX2Ultra home-gallery #

Now ignoreSheband is false, and version is displayed.

I believe that exiftoolPath is being called directly, instead of calling perl with exiftoolPath.

Expected behavior Shouldn't ignoreShebang = true be enough to avoid the inexistance of perl in /usr/bin?

Environment WD My Cloud EX2 Ultra OS5 5.27.157 with Entware

Linux MyCloudEX2Ultra 4.14.22-armada-18.09.3 #1 SMP Thu Oct 27 08:25:39 UTC 2022 ga-18.09.3 Build-30 armv7l GNU/Linux

Installed entware packages perl and perlbase-cpan (for strict)

Perl v5.28.1 Node.js v18.17.1

Thank you!

mceachen commented 6 months ago

Shouldn't ignoreShebang = true be enough to avoid the inexistance of perl in /usr/bin?

You also need to make sure /opt/bin is in your $PATH -- but I found that, depending on your setup, it still might not work properly. I've adjusted how we spawn exiftool in this next version, so at least you'll see a proper error message.

Thanks for taking the time to report this!

mceachen commented 6 months ago

I just released v24.2.0 with this fix :tada:

aztech55 commented 6 months ago

@mceachen , Thank you very much for your quick work!!!