codesandbox-importers
codesandbox-importers copied to clipboard
Cli fails to wait for user to input token on WSL
On Windows Bash (WSL), after clicking yes to "We will open CodeSandbox" and then yes to "We will open CodeSandbox to finish the login process", it shows a link to the login but the browser doesn't load. It also doesn't work manually as the program exits before allowing the user to input a token.
The browser probably isn't launching because on WSL, windows apps must have .exe appended like chome.exe. I'm able to click on the provided link, log into Github and get a token, but unfortunately I can't input it because the program has already exited.
Not just on WSL, just confirmed the prompt doesn't wait for the user to input the token using git bash (on Windows 10) either. Also don't see a way (at least after checking codesandbox --help
) to manually save a token.
Figured out the problem is with the opn package. It is attempting to spawn a process to cmd.exe, but on WSL it's not in the path by default (at least it wasn't for me). I added it and it now works, although on WSL they should make it use whatever the current shell is instead of hardcoding cmd.exe (assuming that would work).
I'm not sure why this fails but I noticed that it's a node version specific issue. Node 10.15.0 - browser window not opening & token input not displayed - not exporting Node 8.15.0 - browser window opens & exporting is working
Tested on Window 10 (64bit) with nvm.
I'll check if this is an issue with opn package.
Tested latest version 5.4.0 with opn-cli
and it's opening the browser. I also checked the history and I don't see anything Windows or Node v10 related in opn-cli since 5.1.0
Thanks for the reply. I got it to work by adding cmd to my path within the WSL environment, but IMO opn needs to add support for WSL. Here's the issue I put up over there awhile back: https://github.com/sindresorhus/opn/issues/106.
My situation might be a bit less common since I'm stripping the Windows path that gets added by WSL in my .bashrc (due to various problems). But I don't think I'm the only one who does that and I think there's now even a built in option to do that in WSL's config.
edit: perhaps you might consider throwing an Error if opn fails. Right now it fails silently and isn't easy to debug.