denon icon indicating copy to clipboard operation
denon copied to clipboard

Running scripts in %PATH%: Uncaught NotFound

Open quaos opened this issue 5 years ago • 10 comments

Describe the bug I'm working on both Windows 10 and MacOS machines. Now running on Windows, I'm trying to setup denon script to call denopack which is in my %HOME%\.deno\bin and already included in %PATH% but got error: Uncaught NotFound: The system cannot find the file specified. (os error 2)

To Reproduce

  1. Create denon.json
"scripts": {
        "build": {
            "cmd": "denopack -c denopack.config.ts",
            "desc": "bundle my client.tsx file",
            "watch": false
        }
}
  1. Check that denopack is installed in %PATH%
where denopack
C:\Users\qua_o\.deno\bin\denopack.cmd

denopack --version
denopack/0.9.0 windows-x86_64 deno-1.3.3
  1. Run denon build

Expected behavior It should run denopack -c denopack.config.ts

Configuration or Project If applicable, add your denon configuration file or project so we can accurately test our solution.

Screenshots

denon build     
[*] [main] v2.4.0
[!] [#0] starting `denopack -c denopack.config.ts`
error: Uncaught NotFound: The system cannot find the file specified. (os error 2)
    at unwrapResponse (rt\10_dispatch_json.js:24:13)
    at sendSync (rt\10_dispatch_json.js:51:12)
    at opRun (rt\40_process.js:20:12)
    at Object.run (rt\40_process.js:104:17)
    at Runner.execute (https://deno.land/x/[email protected]/src/runner.ts:169:17)
    at Object.exe (https://deno.land/x/[email protected]/src/runner.ts:45:21)
    at Daemon.start (https://deno.land/x/[email protected]/src/daemon.ts:62:29)
    at Daemon.iterate (https://deno.land/x/[email protected]/src/daemon.ts:165:32)
    at iterate.next (<anonymous>)
    at https://deno.land/x/[email protected]/denon.ts:162:18

Setup

  • OS: Windows 10
  • Deno version: 1.3.3
  • Denon version: 2.4.0

Additional context It can't neither find and run denon itself in %PATH%.

quaos avatar Sep 19 '20 15:09 quaos

Just tested in Mac OS, it could run normally.

which denon
/Users/quaos/.deno/bin/denon

denon --version
[*] [main] v2.3.3

denon build
[*] [main] v2.3.3
[!] [#0] starting `denopack -c denopack.config.ts`
Generated denopack config: {
  input: "src/client.tsx",
  output: { dir: "./public/assets/js", sourcemap: true, format: "es" },
  plugins: [
    { name: "denopack-plugin-importResolver", resolveId: [Function: resolver] },
    { name: "denopack-plugin-cacheLoader", load: [AsyncFunction: load] },
    { name: "denopack-plugin-fileLoader", load: [AsyncFunction: load] },
    {
      name: "denopack-plugin-typescriptTransform",
      transform: [AsyncFunction: transform]
    }
  ]
}
denopack completed in 8275ms
[*] [daem] clean exit - denon is exiting ...

quaos avatar Sep 21 '20 08:09 quaos

I think this could be an issue related to Deno.run. I will look into this.

notfilippo avatar Sep 30 '20 07:09 notfilippo

I think this could be an issue related to Deno.run. I will look into this.

Thanks.

As for now, I'm using workaround like this:

    let cmd = ["denopack", "-c", "denopack.config.ts"];
    // Workaround for Windows
    // @ts-ignore TS2367
    if (/^(win|windows)$/.test(Deno.build.os)) {
      cmd = ["cmd", "/c"].concat(cmd);
    }
    const process: Deno.Process = Deno.run({
      cmd,
      env: Deno.env.toObject(),
    });

quaos avatar Oct 02 '20 02:10 quaos

I can't seem to replicate this on my windows machine? But I will make a patch for it anyways as it seems like a harmless thing to do which should solve your and other peoples problems. #105 should fix your issue

eliassjogreen avatar Oct 02 '20 08:10 eliassjogreen

Also update your deno version 😉

eliassjogreen avatar Oct 02 '20 08:10 eliassjogreen

The fix for this seems to be causing issues for me. With cmd /c used, when denon restarts the process, it closes the cmd process but deno processes that were launched from it stay open. In my case this prevents the new process from binding to the same port and it crashes. Removing the fix solves this.

PavelFlegr avatar Nov 07 '20 13:11 PavelFlegr

Relevant: #49 #7824

@PavelFlegr Think you could submit a pr for it and I will reopen this issue as it not properly closing seems like a bigger issue?

eliassjogreen avatar Nov 08 '20 00:11 eliassjogreen

To solve this issue I think we should be able to manually just resolve the %path%/tool path and run that instead.

eliassjogreen avatar Nov 08 '20 00:11 eliassjogreen

It's a very small change but here's the pr https://github.com/denosaurs/denon/pull/110

PavelFlegr avatar Nov 08 '20 10:11 PavelFlegr

Window 10: 19042.630

$ deno --version 
deno 1.5.4 (bc79d55, release, x86_64-pc-windows-msvc)
v8 8.8.278.2
typescript 4.0.5

$ denon -v
[*] [main] v2.4.4

Create denopack.ts file:

console.log('this is denopack');
console.log(Deno.args);

and install it:

$ deno install denopack.ts
Check file:///C:/Users/path/to/denopack.ts
✅ Successfully installed denopack
{
  "$schema": "https://deno.land/x/denon/schema.json",
  "scripts": {
    "start": {
      "cmd": "denopack -c denopack.config.ts",
      "desc": "run my app.ts file"
    }
  }
}

Let run

$ denon start
[*] [main] v2.4.4
[*] [daem] watching path(s): *.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `denopack -c denopack.config.ts`
this is denopack
[ "-c", "denopack.config.ts" ]
[*] [daem] clean exit - waiting for changes before restart

image

Hmmm! No error :)

Can you change denopack -c denopack.config.ts to echo %PATH% or where denopack and check output.

hong4rc avatar Dec 07 '20 14:12 hong4rc