TheTechsTech / node-7z-archive

ESM front-end to 7-Zip, featuring alternative 7z CLI tool, binaries for Linux, Windows, Mac OSX, and seamlessly create 7zip SFX self extracting archives targeting different platforms.
MIT License
13 stars 7 forks source link

Installing on Windows puts binaries in unexpected location #6

Closed SeinopSys closed 3 years ago

SeinopSys commented 3 years ago

I just attempted to use this package on Windows 10 version 20H2 (build 19042.1237) 64-bit, with Node.js v14.17.3 and npm v7.24.0, and it seems the downloaded binaries are not in the expected location.

To reproduce, run the following commands in an empty directory (C:\Users\username\folder is used as an example)

  1. npm init --yes
  2. npm install node-7z-archive
  3. node_modules\.bin\createArchive pkg.zip package.json

Instead of creating the archive pkg.zip an error message is displayed:

C:\Users\username\folder>node_modules\.bin\createArchive pkg.zip package.json
Creating/adding...
CreateArchive failed using `7z`, retying with `7za`.
--- error:
Error: spawn C:\Users\username\folder\node_modules\node-7z-archive\binaries\win32\7za.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\username\\folder\\node_modules\\node-7z-archive\\binaries\\win32\\7za.exe',
  path: 'C:\\Users\\username\\folder\\node_modules\\node-7z-archive\\binaries\\win32\\7za.exe',
  spawnargs: [ 'a', 'pkg.zip', 'package.json', '-ssc', '-y', '-bb2' ]
}

Inspecting the installed package folder, it seem the binaries folder has an additional layer of nesting which is not accounted for:

C:\Users\username\folder>tree node_modules\node-7z-archive\binaries /F
Folder PATH listing
Volume serial number is 00000001 FE80:0001
C:\USERS\USERNAME\FOLDER\NODE_MODULES\NODE-7Z-ARCHIVE\BINARIES
└───win32
    └───other32
            7z.dll
            7z.exe
            7za.dll
            7za.exe
            7zCondarwin.sfx
            7zConlinux.sfx
            7zConwin32.sfx
            7zwin32.sfx
            7zxa.dll

The 7za.exe file is executed as binaries\win32\7za.exe but the location on disk is actually binaries\win32\other32\7za.exe.

SeinopSys commented 3 years ago

I just tried to do a fresh install again and the necessary files appeared, I have no idea what causes this but looks like it was a temporary issue.

TheTechsTech commented 3 years ago
1. `npm init --yes`

2. `npm install node-7z-archive`

3. `node_modules\.bin\createArchive pkg.zip package.json`

Instead of creating the archive pkg.zip an error message is displayed:

C:\Users\username\folder>node_modules\.bin\createArchive pkg.zip package.json
Creating/adding...
CreateArchive failed using `7z`, retying with `7za`.
--- error:
Error: spawn C:\Users\username\folder\node_modules\node-7z-archive\binaries\win32\7za.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\username\\folder\\node_modules\\node-7z-archive\\binaries\\win32\\7za.exe',
  path: 'C:\\Users\\username\\folder\\node_modules\\node-7z-archive\\binaries\\win32\\7za.exe',
  spawnargs: [ 'a', 'pkg.zip', 'package.json', '-ssc', '-y', '-bb2' ]
}

Inspecting the installed package folder, it seem the binaries folder has an additional layer of nesting which is not accounted for: ... ... ...

The 7za.exe file is executed as binaries\win32\7za.exe but the location on disk is actually binaries\win32\other32\7za.exe.

It could haved happened for a couple of reasons.

You might want to install package globally, those scripts in '.bin' folder expects itself to be executed in that fashion.

They was tested that way only, not from current node module directory as you have it executed. Thereafter just createArchive pkg.zip package.json.

The folder layout is correct. Some files are stored that way depending on system platform installed onto.