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

fix(examples): fix jest example on windows #2178

Merged
merged 1 commit into from
Nov 27, 2020

Conversation

lukasholzer
Copy link
Collaborator

@lukasholzer lukasholzer commented Sep 8, 2020

Fixes #1454

image

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (please, look at the "Scope of the project" section in the README.md file)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@alexeagle
Copy link
Collaborator

Failing on CI


INFO: From Testing //:test:
--
  | ==================== Test output for //:test:
  | Error: Can't find a root directory while resolving a config file path.
  | Provided path to resolve: ./jest.config.js
  | cwd: C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\examples_jest
  | at _default (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\resolveConfigPath.js:69:11)
  | at readConfig (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\index.js:152:49)
  | at readConfigs (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\index.js:373:26)
  | at C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-cli\node_modules\@jest\core\build\cli\index.js:155:58
  | at Generator.next (<anonymous>)
  | at asyncGeneratorStep (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-cli\node_modules\@jest\core\build\cli\index.js:108:24)

do you know how to fix?

@@ -1 +1,6 @@
import %workspace%/../../common.bazelrc

# Do not build runfile forests by default. If an execution strategy relies on runfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, thanks for the links! It seems like this isn't particular to the jest example, right? Maybe we should have this in the /common.bazelrc so it gets picked up by all our tests, as well as new workspaces created with @bazel/create ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea! that is a good Idea this will also help normal run files (nodejs_binary) to work on windows.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Moved it into the common bazelrc

# Need to set the pwd to avoid jest needing a runfiles helper
# Windows users with permissions can use --enable_runfiles
# to make this test work
"no-bazelci-windows",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice thanks for removing one of these

@lukasholzer
Copy link
Collaborator Author

Failing on CI


INFO: From Testing //:test:
--
  | ==================== Test output for //:test:
  | Error: Can't find a root directory while resolving a config file path.
  | Provided path to resolve: ./jest.config.js
  | cwd: C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\examples_jest
  | at _default (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\resolveConfigPath.js:69:11)
  | at readConfig (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\index.js:152:49)
  | at readConfigs (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-config\build\index.js:373:26)
  | at C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-cli\node_modules\@jest\core\build\cli\index.js:155:58
  | at Generator.next (<anonymous>)
  | at asyncGeneratorStep (C:\users\b\_bazel_b\o3fgohdy\execroot\examples_jest\node_modules\jest-cli\node_modules\@jest\core\build\cli\index.js:108:24)

do you know how to fix?

I'm currently on it – seems that the runfilesHelper has a bug on windows as well (need to debug the wall of rc flags that are used on the ci :D).

@lukasholzer
Copy link
Collaborator Author

@alexeagle The updated regex in the launcher.sh fixes all issues where this error message occured: ERROR: Manifest file c:\Users\ADMINI~1\_BAZEL~1\rgyky3dz\execroot\EXAMPL~1\bazel-out\x64_windows-fastbuild\bin\test.bat.runfiles\examples_jest\test.bat.runfiles_manifest does not exist.

The problem is that the msys2 package sometimes writes paths with a lower letter: c:\tmp\qwm2tovj\execroot\dynatr~1\bazel.... This results in going into the if and appending the current working directory so the BAZEL_NODE_PATCH_REQUIRE had always a wrong path on windows. Wich results in that some nodejs_tests where crashing.

@lukasholzer
Copy link
Collaborator Author

lukasholzer commented Sep 17, 2020

@alexeagle can you help me with the failing ci – suddenly the whole ci seems to fail. No clue why. Locally it is working well:

image

@alexeagle
Copy link
Collaborator

sorry I haven't had time to repro, maybe someone in Slack #javascript can help?

dae added a commit to ankitects/rules_nodejs that referenced this pull request Oct 28, 2020
I was finding the run and test commands on a nodejs binary on
Windows gave an error message similar to the one mentioned in the
following post when --enable_runfiles is passed in on the command line:

bazelbuild#2178 (comment)

Running with --noenable_runfiles, the tests worked correctly, but
other packages in my repo require runfiles.

This patch changes the resolution to use the MANIFEST file inside
the runfiles folder when runfiles are enabled, which seems to fix
the issue.
dae added a commit to ankitects/rules_nodejs that referenced this pull request Oct 28, 2020
I was finding the run and test commands on a nodejs binary on
Windows gave an error message similar to the one mentioned in the
following post when --enable_runfiles is passed in on the command line:

bazelbuild#2178 (comment)

Running with --noenable_runfiles, the tests worked correctly, but
other packages in my repo require runfiles.

This patch changes the resolution to use the MANIFEST file inside
the runfiles folder when runfiles are enabled, which seems to fix
the issue.
dae added a commit to ankitects/rules_nodejs that referenced this pull request Oct 29, 2020
I was finding the run and test commands on a nodejs binary on
Windows gave an error message similar to the one mentioned in the
following post when --enable_runfiles is passed in on the command line:

bazelbuild#2178 (comment)

Running with --noenable_runfiles, the tests worked correctly, but
other packages in my repo require runfiles.

This patch changes the resolution to use the MANIFEST file inside
the runfiles folder when runfiles are enabled, which seems to fix
the issue for me.
@alexeagle
Copy link
Collaborator

hey @lukasholzer I tried to green this up, but still failing on windows:


>>>> FAIL: The node binary 'nodejs_linux_amd64/bin/nodejs/bin/node' not found in runfiles.
--
  | This node toolchain was chosen based on your uname ' x86_64'.
  | Please file an issue to https://github.com/bazelbuild/rules_nodejs/issues if
  | you would like to add your platform to the supported rules_nodejs node platforms. <<<<

could you TAL?

@alexeagle alexeagle added the need: investigation Requires some digging to determine if action is needed label Nov 10, 2020
@lukasholzer
Copy link
Collaborator Author

@alexeagle I get now a different error locally when running: bazel run //examples:examples_jest

image

@lukasholzer lukasholzer force-pushed the fix-jest-windows branch 2 times, most recently from 23cc9bd to 73aa64e Compare November 26, 2020 10:49
Copy link
Collaborator

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@alexeagle alexeagle merged commit cc04f6c into bazelbuild:stable Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest Example fails on Windows
3 participants