Closed groodt closed 7 years ago
You're right. nar
executables are not supported in Windows OS (and honestly I don't have plans to support it in a near future).
That being said, you should be able to run standalone non-executable nar
archives without any issue. Windows was not intensively used and tested (at least from my side), so I can't guarantee it works consistently across Windows OS versions, however, the batch code is pretty simple.
If you provide me some error details, perhaps I can advice you.
Alternatively, you can simply extract the nar
archive as standalone gzip tarball in Windows and eventually run it once extracted. node.bat
script is only used to extend the %PATH%
env variable in order to consume the embedded node
binary in the nar
archive.
In that case, the problem can be related to the fact that the non-executable embedded node
binary is copied from the OS that generated the nar
archive. This is a know limitation, so the easier solution for now would be telling your customers having node.js installed in their Windows systems and having it %PATH%
accessible.
Here is the error we see:
Running application...
\Microsoft was unexpected at this time.
Error: Command failed with exit code: 255
Seems related to: https://support.microsoft.com/en-gb/kb/2524009
And indeed the client does have () in the PATH in some places.
Why is a node binary being embedded if we aren't trying to create the binary nar file? We are intending to use nar create and nar run for normal tarball archives. Node is installed already on the machines.
Are nar files portable across OS if not binary nar and not using any native node packages or is this not possible?
This seems to fix it. I can submit a PR. I'm curious why the logic exists for node binaries if it's known that it isn't supported for Windows?
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
PATH="%~dp0\node_modules.bin:%PATH%"
@IF EXIST "%~dp0.node\lib\node" (
NODE_PATH="%~dp0.node\lib\node"
)
ENDLOCAL
SETLOCAL ENABLEDELAYEDEXPANSION
@IF EXIST "%~dp0.node\bin\node.exe" (
PATH="%~dp0.node\bin:%PATH%"
"%~dp0.node\bin\node.exe" %*
) ELSE (
node %*
)
ENDLOCAL
Why is a node binary being embedded if we aren't trying to create the binary nar file?
There's no binary embedded by default unless you explicitly pass the binary flag via CLI to nar
or add the "binary": true
property at package.json
level.
That being said, the node.bat
script is always used as binary entry point while running nar
archives in Windows. If you can provide a PR; that would be great. Also, a list of tested Windows OS versions would be appreciated.
I'm curious why the logic exists for node binaries if it's known that it isn't supported for Windows?
You're confusing nar
executables with nar
embedded binary concept. nar
can embed a node.js binary just in order to run a custom node.js version that is not the default OS level installed in the machine you execute the nar
archive. The executable is another story and basically allows you to have run nar
a binary itself, instead of a tarball
container.
Ok, I'll aim to submit the PR soon.
Ok, so to clarify, the node.bat script is always used as the entry point. This is so that it can choose to use an embedded node binary (optional) and place it on the PATH.
I just released nar@v0.3.39
on npm
with the fix. Thanks for the PR!
I'm looking into using nar files for one of my clients. They use Windows for development.
I know that it isn't possible to use the nar binary executables, but should it still be possible to run a regular nar tarball file using
nar run...
?The reason I ask, is because we are seeing errors in the node.bat file that nar tries to execute which prevents us using nar as we intended.