Skip to content

ruby_library not using specified SDK version #148

@jgao54

Description

@jgao54

We are testing out the flow where the desired version of ruby is not installed on the host.

I expect for rules_ruby to be able to install and use v2.7.6. (Note this first requires bumping the ruby-build version, which I created a PR here).

With the version specified in WORKSPACE:

load("@bazelruby_rules_ruby//ruby:deps.bzl", "rules_ruby_select_sdk")
rules_ruby_select_sdk(version = "2.7.6")

I can confirm that ruby interpreter that's installed to the @org_ruby_lang_ruby_toolchain external repository is the right version:

➜  org_ruby_lang_ruby_toolchain build/bin/ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [arm64-darwin21]

However, running any ruby_library target i get this error on my macos:

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in 'require': incompatible library version...

I think this requires updating the way the binary wrapper is implemented, which defaults to the first ruby found in PATH today rather than the version that's specified in the SDK:

#!/usr/bin/env ruby

...

def find_ruby_binary
  File.join(
    RbConfig::CONFIG['bindir'],
    RbConfig::CONFIG['ruby_install_name'],
  )
end

In fact, it looks like there was an intention to substitute {interpreter} here but the wrapper script template itself does not have a {interpreter} placeholder anywhere, which looks like a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions