igwgames / create-nes-game

Create and build NES games using ca65/cc65
http://create-nes-game.nes.science/
MIT License
28 stars 2 forks source link

Integration tests failing when I run on my Windows machine #4

Closed mpdunlop closed 1 year ago

mpdunlop commented 1 year ago

I'm unable to build the project or run the integration tests due to errors relating to Unix commands not being present. I assumed this was a problem as I'm running on a Windows machine with nothing installed to provide access to these (no cygwin, no windows subsystem for linux etc) but @cppchriscpp can build this on various Windows machines successfully. I'm opening this ticket in the hope of narrowing down why I'm running into these issues.

I'm using Node version v18.16.0, building using Command Prompt, using Git commit 322c7ae996a8585499bbc3fbe69a69003f76ddb1.

First I run restore node packages:

>npm install

added 202 packages, and audited 203 packages in 37s

30 packages are looking for funding
  run `npm fund` for details

1 high severity vulnerability

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

And then I attempt to build the project with npm run build-all.

The first issue I run into is that the command mv is not found in my environment. I believe this is correct as I'm running on a windows machine, building using Node via a windows command prompt.

>npm run build-all

> create-nes-game@0.0.0 build-all
> npm run pkg && npm run package-win && npm run package-linux

> create-nes-game@0.0.0 pkg
> pkg --public .

> pkg@5.5.2

> create-nes-game@0.0.0 package-win
> mv ./dist/create-nes-game-win.exe ./dist/create-nes-game.exe && cd dist && zip create-nes-game.zip create-nes-game.exe

'mv' is not recognized as an internal or external command,
operable program or batch file.

At this stage, to continue and run the integration tests I manually rename create-nes-game-win.exe to create-nes-game.exe.

I then run node ./test/integration/generate-roms and get the following error (full error attached, relevant snippet below):

[create-nes-game] [error] Failed compiling  null ! Error: spawn ../../../dist/create-nes-game ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn ../../../dist/create-nes-game',
  path: '../../../dist/create-nes-game',
  spawnargs: [
    '--assume-yes',
    '--skip-version-check',
    '--answer',
    'mapper=nrom',
    '--answer',
    'chr-ram=none',
    '--answer',
    'prg-banks=1',
    '--answer',
    'chr-banks=1',
    '--answer',
    'prg-ram=none',
    '--answer',
    'mirroring=horizontal',
    '--answer',
    'use-c=no',
    '--answer',
    'ci-provider=none',
    '--answer',
    'test-provider=nes-test',
    '--answer',
    'emulator=system default',
    '--answer',
    'c-library=none',
    '--answer',
    'neslib-ntsc-or-pal=both',
    '--answer',
    'use-tutorial=no',
    '--answer',
    'tutorial-group=Nerdy Nights',
    '--answer',
    'tutorial-id=Week 3: Background',
    '--answer',
    'name=simple-nrom-128-asm',
    '--answer',
    'chrRam=none',
    '--answer',
    'prgBanks=1',
    '--answer',
    'chrBanks=1',
    '--answer',
    'useC=no'
  ]
}
[create-nes-game] [error] Generating a rom failed! Dumping everything I know and bailing out. {
  e: Error: spawn ../../../dist/create-nes-game ENOENT
      at ChildProcess._handle.onexit (node:internal/child_process:283:19)
      at onErrorNT (node:internal/child_process:476:16)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    errno: -4058,
    code: 'ENOENT',
    syscall: 'spawn ../../../dist/create-nes-game',
    path: '../../../dist/create-nes-game',
    spawnargs: [
      '--assume-yes',
      '--skip-version-check',
      '--answer',
      'mapper=nrom',
      '--answer',
      'chr-ram=none',
      '--answer',
      'prg-banks=1',
      '--answer',
      'chr-banks=1',
      '--answer',
      'prg-ram=none',
      '--answer',
      'mirroring=horizontal',
      '--answer',
      'use-c=no',
      '--answer',
      'ci-provider=none',
      '--answer',
      'test-provider=nes-test',
      '--answer',
      'emulator=system default',
      '--answer',
      'c-library=none',
      '--answer',
      'neslib-ntsc-or-pal=both',
      '--answer',
      'use-tutorial=no',
      '--answer',
      'tutorial-group=Nerdy Nights',
      '--answer',
      'tutorial-id=Week 3: Background',
      '--answer',
      'name=simple-nrom-128-asm',
      '--answer',
      'chrRam=none',
      '--answer',
      'prgBanks=1',
      '--answer',
      'chrBanks=1',
      '--answer',
      'useC=no'
    ]
  },
  args: [
    '--assume-yes',
    '--skip-version-check',
    '--answer',
    'mapper=nrom',
    '--answer',
    'chr-ram=none',
    '--answer',
    'prg-banks=1',
    '--answer',
    'chr-banks=1',
    '--answer',
    'prg-ram=none',
    '--answer',
    'mirroring=horizontal',
    '--answer',
    'use-c=no',
    '--answer',
    'ci-provider=none',
    '--answer',
    'test-provider=nes-test',
    '--answer',
    'emulator=system default',
    '--answer',
    'c-library=none',
    '--answer',
    'neslib-ntsc-or-pal=both',
    '--answer',
    'use-tutorial=no',
    '--answer',
    'tutorial-group=Nerdy Nights',
    '--answer',
    'tutorial-id=Week 3: Background',
    '--answer',
    'name=simple-nrom-128-asm',
    '--answer',
    'chrRam=none',
    '--answer',
    'prgBanks=1',
    '--answer',
    'chrBanks=1',
    '--answer',
    'useC=no'
  ],
  cmd: {
    mapper: 'nrom',
    'chr-ram': 'none',
    'prg-banks': 1,
    'chr-banks': 1,
    'prg-ram': 'none',
    mirroring: 'horizontal',
    'use-c': 'no',
    'ci-provider': 'none',
    'test-provider': 'nes-test',
    emulator: 'system default',
    'c-library': 'none',
    'neslib-ntsc-or-pal': 'both',
    'use-tutorial': 'no',
    'tutorial-group': 'Nerdy Nights',
    'tutorial-id': 'Week 3: Background',
    name: 'simple-nrom-128-asm',
    chrRam: 'none',
    prgBanks: 1,
    chrBanks: 1,
    useC: 'no'
  }
}

The relevant line that is blowing up is in spawn-and-wait.js, namely:

const proc = childProcess.spawn(cmd, args, {cwd: options.cwd ? options.cwd : appConfiguration.workingDirectory});

The error appears to indicate that its running the spawn command (syscall: 'spawn ../../../dist/create-nes-game') but it can't be found, much like the mv command prior.

I'm not sure how to start diagnosing the differences in our build environments, do you have any suggestions?

build-log.txt

potatolain commented 1 year ago

So it does appear that this tool currently requires git-bash to be installed for the mv command. To support your environment, I could write a short node script to do this step in a more friendly way. I'll try to add this when releasing your other change.

The manual rename you did should have worked, though we do end up skipping a few packaging steps.

I'm not sure why it's failing to find create-nes-game for the integration test step - I do recommend using the npm run script rather than running node directly - that will ensure you have the right working directory, and some other minor things. If that works, feel free to ignore the rest of this comment!

Could I ask you to try two things? From the base directory of create-nes-game could you run dir dist to print the directory listing of binaries created.

Then also, try this command, which will directly test if using forward slashes on windows is our problem. (It tries to run the generated create-nes-game with the --version flag)

node -e "require('child_process').spawn('./docs/../dist/create-nes-game', ['--version']).stdout.on('data', t => console.info(t.toString()))"

Here's what those look like on my windows machine, running from cmd (I have a few extra files) image

mpdunlop commented 1 year ago

So it does appear that this tool currently requires git-bash to be installed for the mv command. To support your environment, I could write a short node script to do this step in a more friendly way. I'll try to add this when releasing your other change.

I don't mind installing git-bash if it's useful to the project. Perhaps listing git-bash a pre-requisite for maintainers in the readme.md is enough?

I'll run the other commands and provide an update later today.

mpdunlop commented 1 year ago

I'm have to admit that after running this again tonight I'm not able to reproduce the issue, whether running via node or via npm. I have a feeling I did not rename the executable correctly, which I can't verify now because I reset my repository to work on #3...

And I don't know what I was doing that made me think that running the spawn command with shell execution was necessary.

Thank you for your help and apologies for wasting your time with this!

potatolain commented 1 year ago

No worries, like I said I appreciate the interest! I'm still planning to make the change to swap mv to something cross-platform and release this when I can. Thanks for your attentiveness!