Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug? install.js failed due to incorrect dotnet.exe path matched #12

Open
accelazh opened this issue Jan 8, 2020 · 1 comment
Open

Comments

@accelazh
Copy link
Contributor

accelazh commented Jan 8, 2020

When installing edge-cs, which is a dependent package to my project, tools/install.js failed (see details for error message). It prevents package installation.

Why failed

In install.js, the childProcess.spawn(dotnetPath, .. (line#27) was not using the correct dotnetPath.

The dotnetPath being used was C:\Program Files\dotnet, which is a folder name. However childProcess.spawn expects a executable file name, i.e. C:\Program Files\dotnet\dotnet.exe.

Digging deeper, function whereis allows matching folder name. My environment variable setup made it match C:\Program Files earlier than C:\Program Files\dotnet. (See details)

(I was using Windows 10.)

Details & reproduce

My environemnt %PATH%

...
C:\Program Files;  # This line made `whereis` match folder name rather than file name.
C:\Program Files\dotnet\;
...

My dotnet.exe path

C:\Program Files\dotnet\dotnet.exe

To reproduce. Below is the command that failed installation

E:\...\node_modules\edge-cs>node tools\install.js

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Program Files\dotnet ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Emitted 'error' event at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)
    [... lines matching original stack trace ...]
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
    at ProcessTermError.ExtendableBuiltin (c:\corextcache\NPM.OnCloudbuild.1.0.5-xstore\bin\lib\cli.js:721:66)
    at ProcessTermError.MessageError (c:\corextcache\NPM.OnCloudbuild.1.0.5-xstore\bin\lib\cli.js:750:123)
    at new ProcessTermError (c:\corextcache\NPM.OnCloudbuild.1.0.5-xstore\bin\lib\cli.js:790:113)
    at ChildProcess.<anonymous> (c:\corextcache\NPM.OnCloudbuild.1.0.5-xstore\bin\lib\cli.js:25799:17)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
@accelazh
Copy link
Contributor Author

accelazh commented Jan 8, 2020

For fixing, I changed function whereis to only match file name rather than folder name.

diff --git a/tools/install.js b/tools/install.js
index 5898967..8161203 100644
--- a/tools/install.js
+++ b/tools/install.js
@@ -12,7 +12,7 @@ function whereis() {
     		var filename = arguments[j];
 	        var filePath = path.join(directories[i], filename);
 
-	        if (fs.existsSync(filePath)) {
+	        if (fs.existsSync(filePath) && fs.lstatSync(filePath).isFile()) {
 	            return filePath;
 	        }
 	    }

accelazh added a commit to accelazh/edge-cs that referenced this issue Jan 8, 2020
See Issue#12 for details of this bug

  * tjanczuk#12

For fixing, this patch limit `whereis`
to only match file name rather than folder
name.
accelazh added a commit to accelazh/electron-edge-js that referenced this issue Mar 4, 2020
This is the same bug we found at edge-cs. So port
the fix here too.

For detailed bug descriptor
  tjanczuk/edge-cs#12

For the fix at edge-cs
  tjanczuk/edge-cs#13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant