Open Gozala opened 6 years ago
@Gozala I'm not able to reproduce this locally yet.
is it an issue reproducible from a custom build? Looking at the following code from function that seems to be triggering it (from the stack trace attached above):
a production build should always just take the version from the web-ext package.json file, and it should never call the git.branch and git.long methods.
Do you mind to provide some additional context/STR? (e.g. some details about how the web-ext package has been built and then installed or linked as a dev dependency to trigger this issue).
@rpl I end up running into this when I tried to add web-ext as git dev-dependency. I did run npm install && npm run bulid
postinstall.
Next week is going to be really busy for me, but I'll be able to look more into it to provide more context after I'm back from summit week after.
@Gozala Can you write the exact steps of how we can reproduce the problem? I tried adding web-ext
pulling in mozilla/web-ext
as a devDependency, and can't even get npm run build
to work. Here are the steps that I took:
npm init
npm install --save-dev mozilla/web-ext
(version: 8f03dfde6a8f72a2913c891b2d989a29b7560d83).cd node_modules/web-ext
npm install
to install dependencies.npm run build
(which calls grunt build
).Result (node: this seems related to the "web-ext" directory being inside a node_modules directory; if I rename it to nod_modules
web-ext
will build just fine, but then running web-ext/bin/web-ext run
completes successfully.
Running "clean:dist" (clean) task
>> 1 path cleaned.
Running "webpack:build" (webpack) task
Hash: 0a6be0a291553ba1ec89
Version: webpack 3.11.0
Time: 54ms
Asset Size Chunks Chunk Names
web-ext.js 4.56 kB 0 [emitted] main
web-ext.js.map 2.92 kB 0 [emitted] main
[0] ./src/main.js 239 bytes {0} [built]
[1] ./src/program.js 202 bytes {0} [built] [failed] [1 error]
[2] ./src/cmd/index.js 243 bytes {0} [built] [failed] [1 error]
[3] ./src/util/logger.js 241 bytes {0} [built] [failed] [1 error]
ERROR in ./src/program.js
Module parse failed: Unexpected token (25:5)
You may need an appropriate loader to handle this file type.
|
|
| type ProgramOptions = {|
| absolutePackageDir?: string,
| |}
@ ./src/main.js 2:0-31
ERROR in ./src/cmd/index.js
Module parse failed: Unexpected token (3:12)
You may need an appropriate loader to handle this file type.
| /* @flow */
|
| import type {
| BuildCmdParams, BuildCmdOptions, ExtensionBuildResult,
| } from './build';
@ ./src/main.js 3:0-24
ERROR in ./src/util/logger.js
Module parse failed: Unexpected token (8:7)
You may need an appropriate loader to handle this file type.
| // Bunyan-related Flow types
|
| export type TRACE = 10;
| export type DEBUG = 20;
| export type INFO = 30;
@ ./src/main.js 4:0-40
Warning: Use --force to continue.
Aborted due to warnings.
Reproducible build + test of what I assume is the equivalent bug in 7.6.2 (most of the commit is a workaround for #2981):
❯ nix-build -A web-ext.passthru.tests
this derivation will be built:
/nix/store/x88rykyx82j5k8942z8mymd56ncrrszs-web-ext-tests.drv
building '/nix/store/x88rykyx82j5k8942z8mymd56ncrrszs-web-ext-tests.drv'...
Initialized empty Git repository in /build/.git/
[main (root-commit) 8f95cbc] empty commit
/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:47
throw new Error('[git-rev-sync] no git repository found');
^
Error: [git-rev-sync] no git repository found
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:47:11)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at _getGitDirectory (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:72:10)
at Module.branch (/nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/node_modules/git-rev-sync/index.js:76:16)
at defaultVersionGetter (file:///nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/lib/program.js:303:19)
at async Object.main (file:///nix/store/ns3qqxx2r7j3x1fdrbn12gg9w91xmiy5-web-ext-7.6.2/lib/node_modules/web-ext/lib/program.js:326:19)
Node.js v18.18.2
@l0b0 Adding git-rev-sync is not the solution here. You should build with the --production flag set if the intent is to mimic the actual build procedure.
Note: make sure to build from a specific tag, not a random unreleased commit.
Note: make sure to build from a specific tag, not a random unreleased commit.
I'm running from the 7.6.2 tag.
Is this a feature request or a bug?
This is a bug
What is the current behavior?
If you start a web-extension and did
git init
but have not yet committed any changes this seems to trigger a bug in the implementation causing a crash. Here is the trace:If I create a commit this issue no longer occurs, neither it does if
git init
has not being run. It is also worth noting that.git/packed-refs
does not exists after first commit as well, but presumably something else does causing differ code path.What is the expected or desired behavior?
web-ext run
should behave same regardless of git repo stateVersion information (for bug reports)