From 8662202a52ff890ad5d6065463c9eabbb0cf05b1 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Thu, 13 Sep 2018 02:54:09 -0700 Subject: [PATCH] /bin/bash does not exist on certain systems Bazel and rules_scala refer to `/bin/bash` which does not exist on certain systems. In particular on [NixOS](https://nixos.org/) where the issue was discovered. Replacing `/bin/bash` by `/usr/bin/env bash` resolves the issue. On NixOS this problem is usually circumvented by the corresponding package description for bazel patching these paths. However, rules_scala downloads the `java_stub_template` directly from the GitHub repository. See the corresponding [issue on rules_scala][rules_scala_issue] for more information. This PR replaces `/bin/bash` by `/usr/bin/env bash` in `java_stub_template`. [rules_scala_issue]: https://github.com/bazelbuild/rules_scala/issues/595 Closes #5979. PiperOrigin-RevId: 212782646 --- .../build/lib/bazel/rules/java/java_stub_template.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt index d4d66c9b0385bb..f36d77b2fc3ba7 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/java_stub_template.txt @@ -1,4 +1,4 @@ -#!/bin/bash --posix +#!/usr/bin/env bash # Copyright 2014 The Bazel Authors. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,6 +44,8 @@ # # The remainder of the command line is passed to the program. +set -o posix + # Make it easy to insert 'set -x' or similar commands when debugging problems with this script. eval "$JAVA_STUB_DEBUG"