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

Side-by-side support of different bazel versions #4396

Closed
RNabel opened this issue Jan 8, 2018 · 1 comment
Closed

Side-by-side support of different bazel versions #4396

RNabel opened this issue Jan 8, 2018 · 1 comment

Comments

@RNabel
Copy link
Contributor

RNabel commented Jan 8, 2018

ATTENTION! Please read and follow:

Description of the problem / feature request:

Support for multiple versions installed side-by-side by default. Maybe a built in way to switch between them. My apologies if this belongs in the discussion starter category.

Feature requests: what underlying problem are you trying to solve with this feature?

Concurrent work on multiple projects using different versions of bazel. See this PR against homebrew for further context.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

N/A

What operating system are you running Bazel on?

macOS.

What's the output of bazel info release?

N/A

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

N/A

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

N/A

Have you found anything relevant by searching the web?

Yep, a general discussion can be found in this email thread.

Any other information, logs, or outputs that you want to share?

N/A

@RNabel
Copy link
Contributor Author

RNabel commented Jun 13, 2018

There's a workaround for this: place a shell script called bazel within the tools folder of your workspace which invokes the correct bazel binary. When you run bazel from within your workspace, it checks whether there is a file called tools/bazel and, if so, executes it with all the arguments itself was called with.

Thus, you can have different versions installed under, say, ~/.bazel_installations/<version>/, which the script checks and delegates to it:

if [ -f "${BAZEL_TARGET_PATH}" ]; then
  exec -a "$0" "${BAZEL_TARGET_PATH}" "$@"
fi

or downloads it if it is not present and invokes it once it's placed at the right location.

Note:

  • Doesn't work on Windows (because bazel on linux / macos is a bash script checking tools/bazel but on Windows bazel is the straight-up binary)
  • From version 0.14.0 onwards the bazel team publishes binary-only versions for all platforms, meaning that your script under tools/bazel only needs to download the binary and mv it to the correct location.

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

No branches or pull requests

2 participants