Open vg250156 opened 2 years ago
I have my test project repo here: https://github.com/vg250156/ruby-rules-test/
To reproduce, ensure there is no ruby
in PATH, then execute bazel run //:bar
I think most people rely on the preinstalled or rbenv-managed ruby.
While our rules do build ruby if none is found, this code path has not been widely used or tested.
In order for #!/usr/bin/env ruby
to work the binary folder must simply be in the $PATH
The rules that build ruby interpreter were forked from the Sorbet project. Perhaps you can create an issue there or see how they set this up?
I would love to work with you on solving this together. Let me know if you are down.
Running into this problem as well! The created ruby_binary
is actually not using the pre-built interpreter but my system Ruby (which happens to be a different version breaking everything 😅).
Looking through the code it seems that the right interpreter binary is passed to the ruby_binary wrapper https://github.com/bazelruby/rules_ruby/blob/master/ruby/private/binary.bzl#L68 but the interpreter value is actually not used in the wrapper template itself https://github.com/bazelruby/rules_ruby/blob/master/ruby/private/binary_wrapper.tpl.
Secondly the interpreter executable is not added to the runfiles of the ruby_binary https://github.com/bazelruby/rules_ruby/blob/master/ruby/private/binary.bzl#L75-L78, so even if it would be used within the wrapper Ruby still wouldn't be able to find it.
Not a Bazel expert by far, so my observations could be completely wrong 🙈
Looking for additional core maintainers: https://github.com/bazelruby/rules_ruby/discussions/146
Hello, I'm looking for usage information on this project, looking to incorporate it into an existing mono-repo. For our purposes as a primarily golang project, I can't rely on ruby already being pre-installed on our devs' machines, so I'm doing this in a VM that doesn't have ruby installed. A very basic install with the WORKSPACE, BUILD.bazel, a Gemfile and a ruby source file fails to
bazel run
with/usr/bin/env: ‘ruby’: No such file or directory
It will also output a DEBUG message with
DEBUG: /home/vince/.cache/bazel/_bazel_vince/acbc1f1ef0fcc039a89f9e3efce79ee0/external/bazelruby_rules_ruby/ruby/private/toolchains/ruby_runtime.bzl:91:14: Can't find ruby interpreter in the PATH
This is due to the build target boilerplate calling
/usr/bin/env ruby
in a shebang. I would have assumed thatrules_ruby
would put the ruby that it has just built into PATH when executing aruby_binary
but this apparently isn't the case. Is there some kind of WORKSPACE invocation I'm missing? How can I get it to use the ruby that it's installing?