Enable the ability to run a binary manually
Closed this issue · 2 comments
Hi,
I was using this, and bazel run //:whatever_binary
works great, but if you try to run it manually via bazel-bin/whatever_binary.rb.sh
, it will fail to find the relative path to the executable.
A simple patch will fix ithis.
index 4cd69dca..72771452 100644
--- ruby/private/binary.bzl
+++ ruby/private/binary.bzl
@@ -59,7 +59,7 @@ def generate_rb_binary_script(ctx, binary, bundler = False, args = [], env = {},
toolchain_bindir = toolchain.bindir
if binary:
- binary_path = binary.short_path
+ binary_path = "${BUNDLE_BIN}/" + binary.basename
else:
binary_path = ""
I can fork and make a PR if that is desired, but its a simple change, so i decided to create it as an issue.
Thanks.
edit: Also i'm not sure if this change will actually break anything else.
Ultimately it would be nice to be able to run the command directly.
@taekahn I would appreciate if you open a PR with this change so that at least Ci runs - there might be some problems on Windows
So in the next version, you should be able to use binaries directly, I even dropped.rb.sh
suffix so it looks like a regular binary, for example:
$ bazel build @ruby//...
$ bazel-bin/external/ruby/ruby --version
jruby 9.4.5.0 (3.1.4) 2023-11-02 1abae2700f OpenJDK 64-Bit Server VM 11.0.20+8-LTS on 11.0.20+8-LTS +jit [arm64-darwin]
# This only works for `rb_bundle_fetch()` repository rule
$ bazel build @bundle//...
$ bazel-bin/external/bundle/bin/rspec --version
RSpec 3.11
- rspec-core 3.11.0
- rspec-expectations 3.11.1
- rspec-mocks 3.11.1
- rspec-support 3.11.1
You can probably take it even further and add bundle-bin/external/ruby
/ bundle-bin/external/bundle/bin
to the PATH
.
Note that Windows is not supported at the moment.