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

[BUG] Firefox doesn't install when using a installler made with electron-builder. #2539

Closed
sentoxaio opened this issue Jun 11, 2020 · 18 comments

Comments

@sentoxaio
Copy link

sentoxaio commented Jun 11, 2020

Context:

  • Playwright Version: ^1.1.0-next.1591850160480
  • Operating System: Window
  • Node version: v14.1.0.
  • Browser: Firefox
  • Extra: Compiled Electron App/Installer made with electron-builder

Describe the bug
Playwright works perfectly if it isn't compiled but once I package the app with electron-builder and run the installer on a different device I get a error when running the playwright.
Thats the error:
image

Seems like playwright's firefox browser is execluded by the installer.

@dgozman
Copy link
Contributor

dgozman commented Jun 12, 2020

Thank you for filing an issue. Could you please provide more details? Ideally, it would be some repro steps like "clone this, run this, deploy here, see this error".

Without a repro, I have a number of questions:

  • Are you using playwright-electron to automate electron?
  • How is Firefox related to the compiled electron app? I cannot find any mentions of Firefox with electron-builder.
  • It seems like you miss the downloaded Firefox binary. Did you run npm install? Were there any errors?

@sentoxaio
Copy link
Author

sentoxaio commented Jun 12, 2020

Are you using playwright-electron to automate electron?

  • No, playwright has no influence on electron, its just used to run a script.

How is Firefox related to the compiled electron app? I cannot find any mentions of Firefox with electron-builder.

  • What I meant by that was that when I run it on my computer where I have globally installed playwright it all works perfectly. But once I build the electron app with all the modules, playwright should normally also should be completely included since its in the package.json. But once a user runs the installer on their device it seems not to install everything from playwright since the error says that firefox is missing. The installer I build is only 68 MB big which is another proof that it the browsers didn't got packed.

It seems like you miss the downloaded Firefox binary. Did you run npm install? Were there any errors?

  • As I said I don't have the error on my computer since I ran npm install but normally the installer should do the same but it doesn't.

I hope you can now understand my issue a bit better.

@dgozman
Copy link
Contributor

dgozman commented Jun 12, 2020

Thanks, this helps.

So, if I understand correctly, the electron-builder should run npm install for playwright, and when it does so, the browsers are downloaded in the shared location that is not bundled.

You can try to run the bundler with PLAYWRIGHT_BROWSERS_PATH=0 to download browsers inside the node_modules folder. However, the end user will have to use PLAYWRIGHT_BROWSERS_PATH=0 when running the playwright script, so that Playwright uses browsers from the node_modules. Would this work?

@sentoxaio
Copy link
Author

sentoxaio commented Jun 12, 2020

"electron-builder should run npm install for playwright"

  • I'm not sure if thats the right thing to say. Electron builder just packs all the packages and code but it doesn't pack the browsers into the installers. Thats basically the issue

"to use PLAYWRIGHT_BROWSERS_PATH=0 when running the playwright script"

  • The users wont have access to the code so thats not a option

@dgozman
Copy link
Contributor

dgozman commented Jun 12, 2020

"electron-builder should run npm install for playwright"

  • I'm not sure if thats the right thing to say. Electron builder just packs all the packages and code but it doesn't pack the browsers into the installers. Thats basically the issue

Well, someone has to run npm install, otherwise Playwright won't be able to download browsers. I'd suggest to figure out who is supposed to run playwright's install script. It might as well be the end user, if there is a way to run this file on their machine.

@sentoxaio
Copy link
Author

I know what you mean by that but why did it work for puppeteer then?

@dgozman
Copy link
Contributor

dgozman commented Jun 12, 2020

I know what you mean by that but why did it work for puppeteer then?

Most likely, puppeteer does not download to the shared location, but uses node_modules instead. That's what PLAYWRIGHT_BROWSERS_PATH=0 should do. However, this is just my speculation.

@sentoxaio
Copy link
Author

sentoxaio commented Jun 12, 2020

I think I get what you mean now. This might sound dumb know but how can I install with PLAYWRIGHT_BROWSERS_PATH=0? Is there a doc for it?

Is it just PLAYWRIGHT_BROWSERS_PATH=0 npm install playwright-firefox?

@dgozman
Copy link
Contributor

dgozman commented Jun 12, 2020

That's right. Look at our docs for more information.

@sentoxaio
Copy link
Author

Weird cuz that doesnt work for me
image

@arjunattam
Copy link
Contributor

@sentoxaio, to set the env var in windows, you can run

set PLAYWRIGHT_BROWSERS_PATH=0
npm install playwright-firefox

I'm updating the docs to work across platforms. Sorry for the confusion.

@sentoxaio
Copy link
Author

All good, thank you guys very much

@sentoxaio
Copy link
Author

So I have now playwright and firefox installed in the node_modules and firefox now also appears in the installer, but I still have the same error so it seems like firefox doesn't get launched properly on packaged code (on an exe).

Do you guys have any idea why that is?

@sentoxaio
Copy link
Author

sentoxaio commented Jun 14, 2020

Update:

image
Firefox is actually installed

but I still get this error:
image

@dgozman
Copy link
Contributor

dgozman commented Jun 15, 2020

@sentoxaio I see you closed this one. Does that mean everything worked out?

So I have now playwright and firefox installed in the node_modules and firefox now also appears in the installer, but I still have the same error so it seems like firefox doesn't get launched properly on packaged code (on an exe).

Do you guys have any idea why that is?

You'll have to also pass PLAYWRIGHT_BROWSERS_PATH=0 when running the playwright script (from the packaged app).

@sentoxaio
Copy link
Author

Yeah I got it working now. Thx for your help. Appreciate it a lot

@mattduffield
Copy link

@sentoxaio what did you end up doing for your end users? I am wanting to achieve the same thing. My end users are not at all technical so trying to force them to install dependencies is not an option. Also, they aren't part of a company that could do it for them via a group policy. Just curious how you ended up solving the problem.

@isaacaddis
Copy link

+1 @matt, I'm having the same issue

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

5 participants