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

Terminal can't be opened in Windows 10. #5

Open
triforcely opened this issue Feb 7, 2019 · 7 comments
Open

Terminal can't be opened in Windows 10. #5

triforcely opened this issue Feb 7, 2019 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@triforcely
Copy link
Collaborator

Terminal can't be opened in Windows 10 and method for detecting terminals creates a lot of error message windows.

Expected Behavior

Terminal is opened.

Current Behavior

Following message is displayed for every terminal supported by this library. Finally, target script file is opened in VS Code (I think because it is the default file editor on my PC).

issue

Possible Solution

Detect default terminal executable from system settings instead of using brute-force.
I think that such path is stored in 'ComSpec' env variable in windows.

Context

I tried to attach terminal to my container using "dockly". After investigating the code I noticed that this is caused by this library.

Your Environment

  • Library Version used: The one that is shipped with dockly 3.10.1
  • Node.js version (e.g. Node.js 5.4): v8.9.4
  • Operating System and version (desktop or mobile): Windows 10 Enterprise (1709)
@lirantal lirantal self-assigned this Feb 7, 2019
@lirantal
Copy link
Owner

lirantal commented Feb 7, 2019

Thank you so much for sharing this elaborate report Michal.

I assume we could perhaps add the Windows terminal emulators programs to the list like we see in https://github.com/lirantal/opn-shell/blob/master/lib/TerminalLauncher.js#L10 ?

I don't have a Windows machine easily accessible so it would be a bit of a trail&error for me to get this right. Would you be able to clone this lib and try it out with powershell or cmd as fallbacks? It should be relatively easily to test with the bin/cli.js

I'd be happy to merge a PR to add it if you can work it out.

@lirantal lirantal added the bug Something isn't working label Feb 7, 2019
@triforcely
Copy link
Collaborator Author

Adding terminals to the list won't work well because we will still get message box with error for each terminal that is missing. This is working nicely on linux because nothing is displayed in case of missing executable in PATH.

I'll try to come up with something soon 🙂

@lirantal
Copy link
Owner

lirantal commented Feb 7, 2019

Oh, I realized that this is what you meant. Sorry missed that in the original report.

Well, I think it might be an easy one to solve. I can attempt to detect the OS, if the OS is Windows then I use cmd.exe and that's it (not even trying powershell since that will just pop up an error message too). If we wanted to try the shell detection I could also try to locate powershell as an executable/path and only if that exists to launch it.

Actually, that's not the only thing since the script itself is for bash, so even if we had successfully detected cmd.exe it would just fail to run it. So it sounds like we need a .bat file too or whatever Windows does now :-)

I'm here to support any way I can!

@triforcely
Copy link
Collaborator Author

I've been looking into it today and I'm starting to believe that supporting this feature is impossible with 'opn'. When passing 'cmd' or 'powershell' to opn, scripts are executed in the background - no visible terminal is spawned. When explicitly using "start" command, terminal windows are spawned but the child process spawned by nodejs seems to never exit, because underlying shell is not closed - promises are never fulfilled/rejected and nodejs process does not finish.

Working around this line seems not to be worth it, so I'm going to re-work it a little bit. Linux support will work the same way but windows handlers are going to use bare child_process

@lirantal
Copy link
Owner

lirantal commented Feb 8, 2019

It sounds ok to me to fallback to child_process for Windows.
Let's make it happen :)

@triforcely
Copy link
Collaborator Author

triforcely commented Feb 8, 2019

Most of the implementation is complete but I still have to write some tests and make linters happy. I'll create PR sometime next week because I won't have time to finish this for the next couple of days.

nvm, after writing that I realized that it would be too lazy.

@lirantal
Copy link
Owner

lirantal commented Feb 9, 2019

Awesome thanks! Will check out the PR soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants