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

Bug: non-portable use of #!/bin/bash shebang line breaks builds on FreeBSD/OpenBSD. #328

Closed
4 tasks done
yesudeep opened this issue Oct 22, 2021 · 5 comments
Closed
4 tasks done
Assignees
Labels
P3 We're not considering to work on this, but happy to review a PR. (No assignee) type: feature request

Comments

@yesudeep
Copy link
Contributor

yesudeep commented Oct 22, 2021

The binary for GNU Bash is located at different locations on different operating systems and is largely dependent on the package maintainers. For example:

  • GNU/Linux distributions (generally): /bin/bash
  • MacOS: /bin/bash
  • FreeBSD: /usr/local/bin/bash
  • OpenBSD: /usr/local/bin/bash

The use of #!/bin/bash in the shebang line for shell scripts is non-portable and may require a lot of selective patching for Bazel to build successfully on multiple operating systems if done on a case by case basis. Fortunately, there appears to be a portable workaround if one is acceptable. Please consider using:

#!/usr/bin/env bash instead of #!/bin/bash in the shebang line.

@yesudeep
Copy link
Contributor Author

Noticed this problem when attempting to add a freebsd toolchain for rules_foreign_cc.

bazel-contrib/rules_foreign_cc#794

@tetromino
Copy link
Collaborator

The real fix for this would be Bazel support for the shell toolchain: bazelbuild/bazel#5265

@tetromino tetromino added P3 We're not considering to work on this, but happy to review a PR. (No assignee) type: feature request labels Oct 24, 2021
@tetromino
Copy link
Collaborator

(By the way, please note that Bazel doesn't officially support FreeBSD or OpenBSD. We don't test on any BSD flavor other than macOS in the CI pipeline - which means that things might work on FreeBSD or OpenBSD, but there are no guarantees.)

@yesudeep
Copy link
Contributor Author

Hi @tetromino understood. However, the PR I've sent should unblock a few things without affecting other platforms. Do you think it would be possible to take a look? Since I use Bazel on FreeBSD, I can continue to send patches whenever things break and if I find enough time can have a go at the better fix. wdyt?

@tetromino tetromino self-assigned this Oct 25, 2021
@tetromino
Copy link
Collaborator

Seems reasonable, thanks. I've merged #329.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering to work on this, but happy to review a PR. (No assignee) type: feature request
Projects
None yet
Development

No branches or pull requests

2 participants