web-ext icon indicating copy to clipboard operation
web-ext copied to clipboard

`web-ext run` not working for manifest version 3

Open briankosw opened this issue 3 years ago • 7 comments

Is this a feature request or a bug?

I updated my manifest version to version 3 and I can't use web-ext any longer.

What is the current behavior?

$ web-ext run
Applying config file: ./package.json
Running web extension from
Use --verbose or open Tools > Web Developer > Browser Console to see logging

o: installTemporaryAddon: Error: Error: Could not install add-on: Error: Unsupported manifest version: 3
    at b.installTemporaryAddon (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:43054)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at a.startFirefoxInstance (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:29874)
    at a.run (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:27821)
    at async Promise.all (index 0)
    at x.run (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:5302)
    at $ (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:10140)
    at R.execute (/usr/local/lib/node_modules/web-ext/dist/web-ext.js:1:64498)

error Command failed with exit code 1.

What is the expected or desired behavior?

Version information (for bug reports)

  • Firefox version: 97.0
  • Your OS and version: macOS 10.15.7
  • Paste the output of these commands:
node --version && npm --version && web-ext --version

v17.4.0 8.3.1 6.6.0

briankosw avatar Feb 12 '22 04:02 briankosw

It's a feature request I guess, because its clearly mentioned in error message unsupported manifest version: 3 I guess there should be work in progress o: installTemporaryAddon: Error: Error: Could not install add-on: Error: Unsupported manifest version: 3

aarmn avatar Mar 09 '22 01:03 aarmn

Perhaps an option like --manifest <path> could be added, so we can use a v2 manifest instead, when testing on Firefox.

guihkx avatar May 06 '22 13:05 guihkx

I guess already there are many switches, there should be a hack within them, and even if there is not, it make sense to fix it with some npmscript / waiting for firefox to adopt it then migrating to v3

aarmn avatar May 08 '22 06:05 aarmn

Also it seems MV3 based extensions with service worker are not supported, e.g.

> web-ext run --browser-console --firefox-preview -t firefox-desktop -s extension

Applying config file: ./package.json
Running web extension from /home/----------------------/extension
Configuring Firefox preferences for Manifest V3
Setting custom Firefox preferences: {
  "extensions.manifestV3.enabled": true
}
Use --verbose or open Tools > Web Developer > Browser Console to see logging

WebExtError: installTemporaryAddon:
Error: Error: Could not install add-on at '/home/----------------------/extension/extension':
Error: background.service_worker is currently disabled
    at RemoteFirefox.installTemporaryAddon (file:///home/----------------------/extension/node_modules/web-ext/lib/firefox/remote.js:100:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async FirefoxDesktopExtensionRunner.startFirefoxInstance (file:///home/----------------------/extension/node_modules/web-ext/lib/extension-runners/firefox-desktop.js:227:27)
    at async FirefoxDesktopExtensionRunner.run (file:///home/----------------------/extension/node_modules/web-ext/lib/extension-runners/firefox-desktop.js:45:5)
    at async Promise.all (index 0)
    at async MultiExtensionRunner.run (file:///home/----------------------/extension/node_modules/web-ext/lib/extension-runners/index.js:72:5)
    at async run (file:///home/----------------------/extension/node_modules/web-ext/lib/cmd/run.js:180:3)
    at async Program.execute (file:///home/----------------------/extension/node_modules/web-ext/lib/program.js:285:7)
    at async file:///home/----------------------/extension/node_modules/web-ext/bin/web-ext.js:13:1

sushantdhiman avatar Jul 04 '22 11:07 sushantdhiman

Also it seems MV3 based extensions with service worker are not supported, e.g.

Firefox doesn't support service workers in extensions yet.

As a workaround, you can create two manifests, one with background: { service_worker: 'path.js' } for Chrome and one with background: { scripts: ['path.js'] } for Firefox.

flytaly avatar Jul 04 '22 12:07 flytaly

In Firefox, we have decided to support Event Pages in MV3, and our developer preview will not include Service Workers (we’re continuing to work on supporting these for a future release).

I'll wait for service worker support, so I don't have to maintain two code-bases

sushantdhiman avatar Jul 05 '22 03:07 sushantdhiman

In Firefox, we have decided to support Event Pages in MV3, and our developer preview will not include Service Workers (we’re continuing to work on supporting these for a future release).

I'll wait for service worker support, so I don't have to maintain two code-bases

In Firefox, we have decided to support Event Pages in MV3, and our developer preview will not include Service Workers (we’re continuing to work on supporting these for a future release).

I'll wait for service worker support, so I don't have to maintain two code-bases

The background service worker support in Firefox is planned but there is still more work needed, we decided to prioritized the event page support because:

  • it provides the same resiliency to extension process termination that the background service worker would have allowed
  • but it still supports a number of DOM API that are not available in a service worker global and would prevent some extension use cases to be covered like they were in manifest_version 2 extensions
  • we plan to enable event page for manifest_version 2 extensions in one of the upcoming Firefox releases to make it easier to gradually transition the extensions code base from manifest_version 2 to manifest_version 3
  • Apple will also support event pages in Safari WebExtensions manifest_version 3 implementation

In terms of compatibility, if your background script doesn't use anything that is only available in a service worker global (or use those only if runtime detection determined that they are available), manifest_version 3 extensions should be able to share the same code base and just use two different manifests.

rpl avatar Jul 05 '22 11:07 rpl

With the forced switch to manifest v3 just around the corner, I'd really like to begin testing manifest v3 support... Any updates on this/plans? We only have like 2-3 months before chrome forces the switch if I understood the announcement right.

ChadBailey avatar Oct 08 '22 04:10 ChadBailey

@ChadBailey what are you looking for exactly? For Firefox, the following command should work:

web-ext run --firefox-preview

willdurand avatar Oct 10 '22 08:10 willdurand

I must be doing something wrong, I still get the explicit failure that manifest version is unsupported. I'll take a second look at it

ChadBailey avatar Oct 10 '22 14:10 ChadBailey

Which web-ext version do you use?

willdurand avatar Oct 10 '22 14:10 willdurand

@willdurand I'm having the same issue. Currently on 7.2.0 for web-ext. Here's my WIP draft, if that's helpful.

maxxcrawford avatar Oct 13 '22 22:10 maxxcrawford

@willdurand I'm having the same issue. Currently on 7.2.0 for web-ext. Here's my WIP draft, if that's helpful.

In this case, the problem was that the manifest.json was invalid in MV3 and that's why it couldn't work with web-ext run. The error said "could not install" only, though.. I am not sure we can surface any other errors.

web-ext lint gives more information (errors).

willdurand avatar Oct 14 '22 08:10 willdurand

I am going to close this issue now given the CLI flag works and we can run valid MV3 add-ons.

willdurand avatar Oct 14 '22 08:10 willdurand

I apologize for wasting your time, I imagine my issues were local only. I still haven't gotten it working properly but the current issues I'm experiencing are completely unrelated to this.

ChadBailey avatar Oct 16 '22 19:10 ChadBailey

@ChadBailey feel free to open new issues if you identify issues that might be fixed on the web-ext side. Also, if you have other issues, maybe you can try to get some help on Matrix.

willdurand avatar Oct 17 '22 07:10 willdurand