Skip to content

RUNFILES env var not always correctly set in case of shell wrapper #635

Closed

Description

@Globegitter

🐞 bug report

Affected Rule

The issue is caused by the rule: nodejs_binary

Is this a regression?

No

Description

I ran into another bug in regards to the runfiles discovery when the nodejs_binary is used in a shell-wrapper and this time it is in regards to the node module discovery. I have a full repro-case which will probably explain the issue better, but I am talking about these lines of code: https://github.com/bazelbuild/rules_nodejs/blob/master/internal/node/node_launcher.sh#L81-L103

If bazel has created the runfiles of the nodejs_binary (i.e. one ran bazel build on that target) and then one runs the wrapper shell target via bazel run, then the ǹode_launcher.sh sets RUNFILES to the runfiles of the underlying binary rather then to the ones of the wrapper script. This itself already can cause bugs, because if I add new dependencies and then just bazel run the wrapper target those will be missing in the runfiles of the underlying target. But also the behaviour is inconsistent because if I never did bazel build/run of the underlying target, then node_launcher.sh finds the correct runfiles. Again might be easier to see when running the reproduction case.

🔬 Minimal Reproduction

Clone https://github.com/globegitter/rules_nodejs_sh_wrapper_repro and follow the steps described here: https://github.com/globegitter/rules_nodejs_sh_wrapper_repro#issue-2

🔥 Exception or Error


Error: //app:app.binary_bin cannot find module 'five' required by ....

🌍 Your Environment

Operating System:

  
elementary OS 5.0 Juno (Ubuntu 18.04)
  

Output of bazel version:

  
0.24.0
  

Rules version (SHA):

  
ff9042a67febb52eae5ad0392a12300b4a394031
  

Anything else relevant?
Seems I can workaround the issue by setting the TEST_SRCDIR env var but have not verified that yet.

Activity

  1. changed the title [-]RUNFILES env var not correctly set in case of shell wrapper[/-] [+]RUNFILES env var not always correctly set in case of shell wrapper[/+] on Mar 29, 2019
  2. Globegitter commented on May 21, 2019

    @Globegitter
    Author

    Just as an update, the workaround we are making use of now is setting TEST_SRCDIR=$(pwd)/.. in the shell wrapper and that does mitigate the issue but a proper fix would be good.

  3. alexeagle commented on Aug 29, 2019

    @alexeagle
    Collaborator

    Let's use this to track removing the shell wrappers altogether.

  4. added this to the 1.0 milestone on Aug 29, 2019
  5. alexeagle commented on Sep 6, 2019

    @alexeagle
    Collaborator

    fixed by #1078

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions