rake-compiler / rake-compiler

Provide a standard and simplified way to build and package Ruby C and Java extensions using Rake as glue.
MIT License
563 stars 124 forks source link

rake-compiler 1.2.4 broken on Ruby 2.5 and below #224

Closed ivoanjo closed 1 year ago

ivoanjo commented 1 year ago

Hello there :wave:!

I work at @datadog on the ddtrace gem. We use the rake-compiler gem to build our native extension, and it's extremely useful, thanks for your work on it! :pray:

Yesterday our CI started failing after it picked up rake-compiler 1.2.4 on Ruby 2.5 and below:

mkdir -p tmp/x86_64-linux/stage/lib
rake aborted!
NoMethodError: undefined method `cleanpath' for #<String:0x000055c199dee558>
/usr/local/bundle/ruby/2.3.0/gems/rake-compiler-1.2.4/lib/rake/extensiontask.rb:166:in `block in define_compile_tasks'
/usr/local/bundle/ruby/2.3.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/bundle/gems/bundler-2.3.26/lib/bundler/cli/exec.rb:58:in `kernel_load'

We've had to pin an older version of rake-compiler to work around this.

The issue seems to be that #relative_path_from in those Rubies doesn't work with strings:

https://github.com/rake-compiler/rake-compiler/blob/77d9294a203a11b39ee2e3d295e91706049b91ea/lib/rake/extensiontask.rb#L166

...I believe the fix would be to change it to:

relative_lib_path = Pathname(lib_path).relative_path_from(Pathname(tmp_path))

I can submit a PR if that helps!

kou commented 1 year ago

Oh, could you open a PR for this?

ivoanjo commented 1 year ago

Sounds good, I should have a PR for this within the next days! (Travelling a bit right now!)

flavorjones commented 1 year ago

I submitted PR #226

kou commented 1 year ago

Could you try 1.2.5?

ivoanjo commented 1 year ago

Yeap, can confirm it works now, thanks for the speedy fix :)