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

Make explainshell work in WSL #42

Open
Ry-DS opened this issue Feb 5, 2023 · 4 comments
Open

Make explainshell work in WSL #42

Ry-DS opened this issue Feb 5, 2023 · 4 comments

Comments

@Ry-DS
Copy link

Ry-DS commented Feb 5, 2023

When you ask terminal-copilot to explain a shell command, it crashes with the following:

> explainshell: https://explainshell.com/explain?cmd=tar%20-xzvf%20%3Cfilename%3E.tar.gz
Traceback (most recent call last):
  File "/home/ryan/.local/bin/copilot", line 8, in <module>
    sys.exit(main())
  File "/home/ryan/.local/lib/python3.8/site-packages/copilot/main.py", line 116, in main
    show_command_options(prompt, cmd)
  File "/home/ryan/.local/lib/python3.8/site-packages/copilot/main.py", line 149, in show_command_options
    show_more_cmd_options(prompt)
  File "/home/ryan/.local/lib/python3.8/site-packages/copilot/main.py", line 179, in show_more_cmd_options
    show_command_options(prompt, cmds[cmd_menu_entry_index])
  File "/home/ryan/.local/lib/python3.8/site-packages/copilot/main.py", line 147, in show_command_options
    subprocess.run(["open", "https://explainshell.com/explain?cmd=" + quote(cmd)])
  File "/usr/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'open'

This is expected, as a WSL instance doesn't have the open ability.

I plan to make a PR to fix this, which will check if the VM is a WSL instance, and if so, use wslview or another command instead to open the URL. ETA for the PR is about a month once I find the time.

No longer use this in preference of github copilot's ai shell: https://githubnext.com/projects/copilot-cli
Probably won't have the time to contribute this, but I'll keep this open for anyone else who runs into this

@github-actions
Copy link

github-actions bot commented Feb 5, 2023

Hey! Thanks for sharing feedback with the community!

@2mawi2
Copy link
Contributor

2mawi2 commented Mar 5, 2023

I am wondering how the browser on WSL can be opened anyway ? You would probably open the browser of the host system. Which is pretty difficult and therefore I am not sure I we want to support this at all ?

@Ry-DS
Copy link
Author

Ry-DS commented Mar 6, 2023

It's very easy, and built into wsl. It's a matter of checking if the OS is running in WSL, and calling wslview <url>

e.g: wslview http://google.com

Check: https://manpages.ubuntu.com/manpages/impish/man1/wslview.1.html

@Ry-DS
Copy link
Author

Ry-DS commented Mar 6, 2023

fun fact you can open exe's even in wsl. powershell.exe -C "wsl --help" > wsl_help.txt is a valid command which will work inside of wsl

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