clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Absolute manifest path cannot be used to initialize a `simnet` session on Windows

Open BowTiedRadone opened this issue 1 year ago • 4 comments

Describe the bug An unexpected error is thrown while attempting to initialize the simnet using an absolute manifest path on Windows. The error message is "unable to mutate url".

To Reproduce Steps to reproduce the behavior:

  1. On a Windows machine, create a minimal Node.js app having the following index.js:
import { initSimnet } from "@hirosystems/clarinet-sdk";
import { resolve } from "path";

const main = async () => {
  const manifestDir = process.argv[2];

  const manifestPath = resolve(manifestDir, "Clarinet.toml");

  console.log(manifestPath);
  await initSimnet(manifestPath);
};

main();
  1. Add a Clarinet project called example at the root of the node app.
  2. Run index.js using the following command:
node index.js example
  1. See error:
$ node index.js example
C:\Users\...\bug-demo\example\Clarinet.toml
node:internal/process/promises:389
      new UnhandledPromiseRejection(reason);
      ^

UnhandledPromiseRejection: This error originated either by throwing inside of an
 async function without a catch block, or by rejecting a promise which was not h
andled with .catch(). The promise rejected with the reason "unable to mutate url
".
    at throwUnhandledRejectionsMode (node:internal/process/promises:389:7)
    at processPromiseRejections (node:internal/process/promises:470:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:3
2) {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v20.18.1

Environment (please complete the following information):

  • OS: Windows

Additional Context The same setup works on Linux and macOS.

BowTiedRadone avatar Dec 23 '24 15:12 BowTiedRadone

Hey @BowTiedRadone, seeing this C:\Users\...\bug-demo\example\Clarinet.toml, isn't this path invalid?

C:\Users\.. is C:\ C:Users\... seems to va invalid to me.

I think this is the issue. Also, looking in details to this, I actually realise that initSimnet takes the relative path to the current working directory. So you need to do path.join(dir, "Clarinet.toml") (join instead of resolve)

Finally, if you want to follow a more "clarinet-like" CLI, we usually take the full path to the manifest, as in

$ clarinet check --manifest-path path/to/Clarinet.toml
# or
$ clarinet check --m path/to/Clarinet.toml

Allowing, not only to have a custom directory but also to have manifest file name (and multiple of them), as in Clarinet_v1.toml, Clarinet_v2.toml, etc

hugoclrd avatar Jan 24 '25 14:01 hugoclrd

Hi @hugocaillard! Sorry for the misunderstanding. Yes, the ... was added to not specify the full path on my machine. The full output is:

$ node index.js example
C:\Users\radub\bug-demo\example\Clarinet.toml
(node:21512) [DEP0040] DeprecationWarning: The `punycode` module is deprecated.
Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/process/promises:392
      new UnhandledPromiseRejection(reason);
      ^

UnhandledPromiseRejection: This error originated either by throwing inside of an
 async function without a catch block, or by rejecting a promise which was not h
andled with .catch(). The promise rejected with the reason "unable to mutate url
".
    at throwUnhandledRejectionsMode (node:internal/process/promises:392:7)
    at processPromiseRejections (node:internal/process/promises:475:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:106:
32) {
  code: 'ERR_UNHANDLED_REJECTION'
}

Node.js v22.12.0

BowTiedRadone avatar Jan 24 '25 16:01 BowTiedRadone

Ok got, will keep investigating then 😅

hugoclrd avatar Jan 24 '25 16:01 hugoclrd

Thank you! 🙏

BowTiedRadone avatar Jan 24 '25 16:01 BowTiedRadone