3

I'm trying to use the Windows chrome executable through WSL2 (for reference, Flutter looks at $CHROME_EXECUTABLE to launch web apps in chrome).

In my bashrc I have the following:

export CHROME_EXECUTABLE="/mnt/c/program\ files/google/chrome/application/chrome.exe"

With this, flutter doctor complains that $CHROME_EXECUTABLE doesn't point to a chrome executable. If I execute $CHROME_EXECUTABLE in bash, I get:

bash: /mnt/c/program\: No such file or directory

If however, I execute /mnt/c/program\ files/google/chrome/application/chrome.exe, It works and opens a chrome instance inside windows.

It seems like there's some escaping issue here, but I'm not sure what's going on, I thought \ would escape the space in "program files" ?

3
  • Did you consider using double quotes around "$CHROME_EXECUTABLE"?
    – RudiC
    Commented Nov 7, 2021 at 13:15
  • That gives bash: /mnt/c/program\ files/Google/Chrome/application/chrome.exe: No such file or directory. Either way, I can't really control how flutter invokes it :/ Commented Nov 7, 2021 at 13:45
  • Use either quotes or backslashes to quote the space, but not both.
    – muru
    Commented Nov 7, 2021 at 14:52

3 Answers 3

2

Full disclosure, I don't use Flutter, so I may be wrong here, but it appears to me from some quick research that Flutter isn't just "launching" Chrome. It really needs a Chromium executable with which to communicate (probably via webdriver) to debug.

If this is truly the case, then using the Windows version of Chrome with the Linux version of Flutter isn't going to work. This is similar to trying to use the Windows version of Chrome with Selenium. That would explain why, even if your path is correct, Flutter would complain that the Windows binary isn't a "Chrome executable."

In that case, the solution would be to install the Linux version of Chrome (or a Chromium) in WSL. To recap solutions from this question, you can do this by:

  • Upgrading to Windows 11, which supports running Linux GUI apps on Windows with WSLg.
  • Using a third-party X server on Windows per harrymc's answer there
  • Using xrdp per my answer there. Here's the direct link to the Ask Ubuntu answer where I provide the full steps.

I have successfully run Selenium on WSL using the xrdp method, at least.

1

You can use the old 8.3 naming style; if Chrome is in C:\progra~1, the command would be

/mnt/c/progra~1/google/Chrome/Application/chrome.exe

To find the appropriate short name, use

DIR C:\ /X
1
  • 1
    They could also just remove the backslash. Also, it would be more common to use an alias than a shell variable.
    – Kusalananda
    Commented May 14, 2022 at 8:38
1
export CHROME_EXECUTABLE="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"

This worked for me

1
  • 1
    Your answer is a bit terse and could be improved by explaining the issue, i.e., the underlying cause of the problem and why your solution correctly would resolve it for the user in the question.
    – Kusalananda
    Commented Jan 9, 2023 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .