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

Doesn't work with VSCode under WSL2 #25

Closed
kirsanium opened this issue Dec 27, 2022 · 16 comments
Closed

Doesn't work with VSCode under WSL2 #25

kirsanium opened this issue Dec 27, 2022 · 16 comments

Comments

@kirsanium
Copy link

kirsanium commented Dec 27, 2022

Set my Chromium path to /mnt/c/Program Files/Google/Chrome/Application/chrome.exe, and after hitting login button I get:
image

I believe in such case tmp path should be on mounted C drive, maybe make it configurable?

I do realize it might be an exotic way to use VS Code for you, but it's the only way I use it and your extension seems to be the only way to use ChatGPT from inside VS Code at all :P

@gencay
Copy link
Owner

gencay commented Dec 27, 2022

Sorry, I'm not familiar with this but my extension doesn't hardcode any tmp/ folders. From the error it looks like it could be a permission issue of chrome.exe on tmp folder? Could you try chmod to allow chrome to access that folder with RW permissions?

@gencay
Copy link
Owner

gencay commented Dec 27, 2022

@kirsanium I released a new version with the mentioned flags set. I don't know if it'll help but it was mentioned in this thread

There is also this troubleshooting guide on how to run puppeteer on WSL https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-wsl-windows-subsystem-for-linux

@kirsanium
Copy link
Author

kirsanium commented Dec 27, 2022

@gencay new version didn't fix the issue on itself. Although I had success opening browser and logging in using the link you provided on how to run puppeteer in WSL, after that VS Code still throws following exception:
Km Unable to login. Make sure to login and keep your browser open. This error may also be due to OpenAI servers down or that it's throttling the requests.
And the button says Protocol error (Runtime.callFunctionOn): Argument should belong to the same Javascript world as target object.
I'm using Google Authentication to log in by the way.

@EzYDark
Copy link

EzYDark commented Jan 3, 2023

@kirsanium
Hey. If you want, you can try my method I posted here #39. Hope it works for you.
I haven't tried WSL yet, but it could work too.

@octrow
Copy link

octrow commented Jan 6, 2023

@kirsanium I released a new version with the mentioned flags set. I don't know if it'll help but it was mentioned in this thread

There is also this troubleshooting guide on how to run puppeteer on WSL https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-wsl-windows-subsystem-for-linux

For me, installing Chrome on Ubuntu Server 22.04.1 inside WSL2 on Windows 11 worked. Thanks for the tip, I didn't know it was possible to run Chrome on Ubuntu Server WSL2 without a GUI!

@EzYDark
Copy link

EzYDark commented Jan 8, 2023

I also tried this extension today in WSL (Debian) and it works perfectly via built-in X11. I just installed Google Chrome in WSL using these commands:

sudo apt install wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb

(Source: https://itsfoss.com/install-chrome-debian-kali-linux/)

And then just set the 'Chromium Path' in VSCode (ChatGPT extension) to 'google-chrome' (without quotes!)

__

It's even easier than I described in #39 for a Remote (SSH) extension.

@gencay
Copy link
Owner

gencay commented Jan 8, 2023

Thanks for your comments again @EzYDark. if somebody else could confirm your solution, I will add it to Readme. 🙏🏼

@kirsanium
Copy link
Author

Can confirm the solution is working now! Closing the issue, thanks to everyone in the comments, and especially to the amazing extension author <3.

@gencay
Copy link
Owner

gencay commented Jan 8, 2023

@kirsanium thanks for confirmation and thanks for your contribution @EzYDark! I updated the readme with references to these issues.

@doublefx
Copy link

My WSL2 shell is zsh and with the @EzYDark solution, I get:

Unable to login. Make sure to login and keep your browser open. This error may also be due to OpenAI servers down or that it's throttling the requests. Error: Error Failed to launch the browser process! /etc/zsh/zshrc: line 31: key: BackSpace: must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: "${terminfo[kbs]}": must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: Home: must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: "${terminfo[khome]}": must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: End: must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: "${terminfo[kend]}": must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: Insert: must use subscript when assigning associative array /etc/zsh/zshrc: line 31: key: "${terminfo[kich1]}": must use subscript when assigning associative array /etc/zsh/zshrc: line 31: k...

@VinceDiR
Copy link

VinceDiR commented Jan 17, 2023

Tried @EzYDark's solution and got the following error:

[4073:4073:0117/165518.793971:ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY [4073:4073:0117/165518.794004:ERROR:env.cc(255)]

Obviously something to do with having X11 tools installed or the display environment variable set correctly but not sure how to proceed as I've tried installing them via these instructions and also tried editing my .zshrc config file to include DISPLAY environment variable.

@shencp
Copy link

shencp commented Feb 9, 2023

Tried @EzYDark's solution and got the following error:

[4073:4073:0117/165518.793971:ERROR:ozone_platform_x11.cc(238)] Missing X server or $DISPLAY [4073:4073:0117/165518.794004:ERROR:env.cc(255)]

Obviously something to do with having X11 tools installed or the display environment variable set correctly but not sure how to proceed as I've tried installing them via these instructions and also tried editing my .zshrc config file to include DISPLAY environment variable.

I met the same issue and I found that compared to the 'GPT3 open AI key' method this 'browser Auto-login' just can invoke the perfect chatGPT APIs.

My environment is: VcXsrv Windows X Server + LXDE Linux desktop + google-chrome

and I think the only key point is to let this extension can read the DISPLAY environment variable when it opens the google-chrome in WSL2.

I've tried to add the DISPLAY environment in /etc/environment or .bashrc but neither of them can work.

while when I open the terminal and use the command line google-chrome can setup normally with the DISPLAY environment variable imported.

@EzYDark any comments from your sides?

@shencp
Copy link

shencp commented Feb 10, 2023

After restarting my laptop, everything seems to work fine right now.
I list the detailed steps right here:

this is my environmental solution:

win10(VcXsrv Windows X Server) + ubuntu20.04(LXDE Linux desktop + google-chrome)

On win10:

  1. INSTALL THE VCXSRV WINDOWS X-SERVER
    pls get the installer right here,https://sourceforge.net/projects/vcxsrv/files/latest/download

  2. RUNNING THE X-SERVER DESKTOP

  • Windows search "xlaunch" and click on "XLaunch" in the
    results. A display settings window should open.
  • Select "One large window" and click "Next".
  • Select "Start no client" and click "Next".

On Ubuntu(WSL2):

  1. INSTALLING AND RUNNING THE LINUX DESKTOP
  • sudo apt install lxde
  • export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0
  • export LIBGL_ALWAYS_INDIRECT=1
  • startlxde
  1. INSTALLING THE google-chrome
  1. CONFIGURATION OF ENVIRONMENT AND VSCODE EXTENSION
  1. add the relevant environment variables in ~/.bashrc to make sure when this VScode extension open the google-chrome can use them.
  • export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0
  1. change the extension configuration
    image

image

  1. The solution of WSL2 connects to VPNs on the Windows host.
    The wsl-vpnkit v0.3 script uses gvisor-tap-vsock to provide network connectivity to the WSL 2 VM while connected to VPNs on the Windows host. This requires no settings changes or admin privileges on the Windows host. pls find the detailed info behind the following link

https://github.com/sakai135/wsl-vpnkit

Don't forget set the proxy in WSL extension settings:
image

@gencay
Copy link
Owner

gencay commented Feb 10, 2023

Thanks for sharing @shencp, If people can confirm this solution happy to take a PR to update the Readme with a reference to your solution.

@dario-github
Copy link

Didn't work for me. Failed to install both packages (lxde/google-chrome)

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 lxde : Depends: lxde-core (>= 0.5.0-4ubuntu4) but it is not going to be installed
        Depends: lxinput (>= 0.1.1) but it is not going to be installed
        Depends: lxterminal but it is not going to be installed
        Depends: obconf but it is not going to be installed
        Recommends: lxdm but it is not going to be installed or
                    x-display-manager
        Recommends: xserver-xorg
        Recommends: policykit-1-gnome
        Recommends: amixer but it is not installable
E: Unable to correct problems, you have held broken packages.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'google-chrome-stable' instead of './google-chrome-stable_current_amd64.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 google-chrome-stable : Depends: libgbm1 (>= 17.1.0~rc2) but 10.1.3-0ubuntu0.6 is to be installed
                        Depends: libu2f-udev but it is not installable
E: Unable to correct problems, you have held broken packages.

@gencay
Copy link
Owner

gencay commented Mar 8, 2023

I released a new version to fix the Protocol error (Runtime.callFunctionOn): Argument should belong to the same JavaScript world as target object error in v3.9.5. You can upgrade your extensions to use Browser Auto-login flow without that exact error now. Similar to #194

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

8 participants