Skip to content

[Bug]: js_run_devserver() leaks .sh in file name #845

@dgp1130

Description

@dgp1130

What happened?

The js_run_devserver() target (on Linux) creates an executable file with the name %{name}.sh, which leaks the fact that this is implemented with Bash under the hood and forces any other scripts which call it via runfiles to add .sh to the filenames. This also likely complicates cross-platform support, since the filename is different for both.

$ bazel query --output build //common/testing:webdriver_test_server
INFO: Invocation ID: ed977d5a-d7cf-47bb-9839-fd2d99d08555
# /home/doug/Source/rules_prerender/common/testing/BUILD.bazel:268:24
js_run_devserver(
  name = "webdriver_test_server",
  tags = ["ibazel_notify_changes"],
  generator_name = "webdriver_test_server",
  generator_function = "web_resources_devserver",
  generator_location = "common/testing/BUILD.bazel:268:24",
  testonly = True,
  data = ["//common/testing:webdriver_test_resources"],
  entry_point = "@aspect_rules_js//js/private:js_devserver_entrypoint",
  enable_runfiles = select({"@aspect_rules_js//js/private:enable_runfiles": True, "//conditions:default": False}),
  tool = "//common/testing:webdriver_test_server_baked_server",
)

$ bazel build //common/testing:webdriver_test_server
INFO: Invocation ID: 9315b831-1936-4983-9a2e-14a064f1e6fa
INFO: Analyzed target //common/testing:webdriver_test_server (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //common/testing:webdriver_test_server up-to-date:
  dist/bin/common/testing/webdriver_test_server.sh
INFO: Elapsed time: 0.207s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

Version

Host is WSL2 in Windows 10.

$ bazel --version
bazel 5.1.1

Using @aspect_rules_js version 1.16.0 via WORKSPACE.

How to reproduce

load("@npm_rules_js//:http-server/package_json.bzl", http_server_bin = "bin")

http_server_bin.http_server_binary(
    name = "server",
)

js_run_devserver(
    name = "devserver",
    tool = ":server",
)

# Omitting runfiles setup...
sh_binary(
    name = "executor",
    srcs = ["executor.sh"],
    data = [":devserver"],
)
# Error: `devserver` does not exist in runfiles.
$(rlocation devserver)

# Works.
$(rlocation devserver.sh)

Any other information?

Ideally the binary file should always be generated with the same name as the target. This is more intuitive to use and more accurately abstracts away the underlying implementation so it can be changed without breaking existing API contracts.

Fund our work

  • Sponsor our open source work by donating a bug bounty

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingRequires a semver-major release due to breaking public API changesbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions