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

Fails with an error with file-paths and filenames containing a space on Windows. #22

Closed
TheStruggleForAntiSpaghetti opened this issue Jul 1, 2020 · 8 comments

Comments

@TheStruggleForAntiSpaghetti

S:\128 Banks Contention Test>call npx txt2bas -f tap -A 10 -i "S:\128 Banks Contention Test\128 Banks Contention Test.bas" -o "128 Banks Contention Test.tap" Error: ENOENT: no such file or directory, open 'S:\128' at Object.openSync (fs.js:440:3) at Object.readFileSync (fs.js:342:35) at main (C:\Users\Mike\AppData\Roaming\npm\node_modules\txt2bas\dist\cli\txt2bas.js:2776:14) at main$1 (C:\Users\Mike\AppData\Roaming\npm\node_modules\txt2bas\dist\cli\txt2bas.js:2906:3) at Object.<anonymous> (C:\Users\Mike\AppData\Roaming\npm\node_modules\txt2bas\dist\cli\txt2bas.js:2911:1) at Module._compile (internal/modules/cjs/loader.js:955:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10) at Module.load (internal/modules/cjs/loader.js:811:32) at Function.Module._load (internal/modules/cjs/loader.js:723:14) at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10) { errno: -4058, syscall: 'open', code: 'ENOENT', path: 'S:\\128' }

@remy
Copy link
Owner

remy commented Jul 2, 2020

Looks like an argument parsing failure.

You can get around it in the mean time by running the command in the same directory and rename your file so it doesn't have spaces.

I'll get a fix out for the bug too.

@TheStruggleForAntiSpaghetti
Copy link
Author

It seems to choke on the folder name though so only renaming the filename won't do.

@remy
Copy link
Owner

remy commented Jul 3, 2020

Ah poo. I'll try to fix that soon - just requires that I dust off the windows machine to test!

@remy
Copy link
Owner

remy commented Jul 16, 2020

I've been looking at this a looking at this a bit more and I wanted to ask about the call at the start of the command. I suspect this is causing the args to the script to be broken up (incorrectly).

Node should read arguments contained in quotes without breaking it apart (and I use this in a highly used command line tool so I'm 99% sure it's "normally" fine).

Can you elaborate on the call command, and are you able to run npx without it?

@TheStruggleForAntiSpaghetti
Copy link
Author

Sorry, just noticed your comment.

Without the call it's not returning to the batch file where it's called from and thus won't process the rest of the build script.

But that doesn't seem to be the issue.

When I enter directly from the command line:
npx txt2bas -f tap -A 10 -i "S:\Bank contention test\128BanksContentionTest.bas" -o "128BanksContentionTest.tap"

it fails with:
Error: ENOENT: no such file or directory, open 'S:\Bank'

It runs successfully when I remove the spaces from the folder name and adjust the parameter accordingly.

When I add a space in the filename, such as:
npx txt2bas -f tap -A 10 -i "S:\Bankcontentiontest\128 BanksContentionTest.bas" -o "128BanksContentionTest.tap"

it again fails with the same error.

@remy
Copy link
Owner

remy commented Jul 28, 2020

So after some digging this turns out to be a long standing issue with npx. npx is failing to parse arguments with spaces in it. For context, npx is parsing the arguments (which include txt2bas, -f, and so on). npx does not see the quotation marks and treats the string as a separate argument.

There's a few work arounds:

  1. Install npm globally: npm install --global txt2bas - now you don't need to use npx and I've confirmed filenames with spaces work.
  2. Call txt2bas directly out of the node_modules directory: node_modules\.bin\txt2bas -f tap …
  3. Use the short filename instead of with spaces: https://stackoverflow.com/a/46871748/22617 (probably the worst option).

Sorry I couldn't be more help, but it looks like this problem is outside of txt2bas.

@remy remy closed this as completed Jul 28, 2020
@TheStruggleForAntiSpaghetti
Copy link
Author

Okay. Thanks for looking into it.
Probably a good idea to include it in the documentation.

@remy
Copy link
Owner

remy commented Jul 28, 2020 via email

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

2 participants