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

Subcommand watch fails when path to tectonic contains spaces #1003

Closed
m-haug opened this issue Feb 20, 2023 · 9 comments
Closed

Subcommand watch fails when path to tectonic contains spaces #1003

m-haug opened this issue Feb 20, 2023 · 9 comments

Comments

@m-haug
Copy link

m-haug commented Feb 20, 2023

It appears that the path to tectonic is not properly quoted before it is passed to the shell for execution in the watch command. See an example below. Note that I translated the actual error message because I was unable to change the UI language for the error message.

> tectonic -X watch
note: "version 2" Tectonic command-line interface activated
[Running `C:\Users\Markus Haug\scoop\apps\tectonic\current\tectonic.exe -X build`]
Command "C:\Users\Markus" could not be found.
[Finished running. Exit status: 0]
@xinslu
Copy link
Contributor

xinslu commented Jun 12, 2023

I am unable to reproduce this on linux amd64. Might be localized to windows?

@m-haug
Copy link
Author

m-haug commented Jun 12, 2023

I can no longer reproduce this under v0.13.1 either. Perhaps it was fixed as part of upgrading watchexec? Either way, I will close this for now.

@m-haug m-haug closed this as completed Jun 12, 2023
@m-haug
Copy link
Author

m-haug commented Jun 12, 2023

I was too fast in closing: tectonic -X watch works fine, but tectonic -X watch -x "build --open" fails.

Checking the code, the former is run directly while the latter is wrapped in a shell.

@m-haug m-haug reopened this Jun 12, 2023
@xinslu
Copy link
Contributor

xinslu commented Jun 13, 2023

Able to replicate this case. I see the error should be a simple fix where I should be able to append the quotes around the tectonic location and should work. I would be able to push a fix right now.

@pkgw
Copy link
Collaborator

pkgw commented Jun 16, 2023

This should be fixed in 0.14.1, which I released the other day.

@pkgw pkgw closed this as completed Jun 16, 2023
@m-haug
Copy link
Author

m-haug commented Jun 21, 2023

Unfortunately, the issue persists with 0.14.1:

$ tectonic --version
Tectonic 0.14.1

$ tectonic -X watch -x "build --open"
note: "version 2" Tectonic command-line interface activated
[Running `"C:\Users\Markus Haug\scoop\apps\tectonic\current\tectonic.exe" -X build --open`]
Der Befehl "\"C:\Users\Markus Haug\scoop\apps\tectonic\current\tectonic.exe\"" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
[Finished Running. Exit Status: 1]

Please excuse the German localization, I'm unable to change the locale for CMD. The error message roughly translates to “Command not found”.

I've dug a bit deeper, and it appears that the problem lies with tokio or watchexec's usage thereof. I've run a series of commands to reproduce the format of the error message:

>uonsdu
Der Befehl "uonsdu" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

C:\Windows\System32>"uonsdu"
Der Befehl ""uonsdu"" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

C:\Windows\System32>\"uonsdu"
Der Befehl "\"uonsdu"" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

C:\Windows\System32>\"uonsdu\"
Der Befehl "\"uonsdu\"" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.

Apparently, the program name gets escaped somewhere down the stack. I will check the tokio docs next, file an issue elsewhere, and update here with progress.

@m-haug
Copy link
Author

m-haug commented Jun 21, 2023

Apparently, the issue is CMD /C parsing being special, as documented in std. I've opened watchexec/watchexec#613 with watchexec to handle this case properly.

@xinslu
Copy link
Contributor

xinslu commented Jun 22, 2023

I see that you're using windows and my tests were conducted on a Linux system that seemed to work. I'm sorry I couldn't really test on a windows machine cuz I didn't really have access to one. Just as a sanity check to make sure I'm doing this right, could you try running this on a linux machine and making sure everything works as intended? Maybe could help narrow this issue down to a windows specific one.

@m-haug
Copy link
Author

m-haug commented Jun 22, 2023

I don't have access to a Linux machine at the moment, but testing version 0.14.1 on WSL worked fine. That makes me pretty certain that the issue is specific to CMD/Windows.

There is also not a lot that tectonic can do about this, as the issue comes down to CMD parsing /C in a special way. This needs to be fixed in watchexec.

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

3 participants