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

extconf.rb Makefile compiles binary into wrong directory depending on OS #202

Open
mgmarlow opened this issue Apr 27, 2023 · 3 comments
Open
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mgmarlow
Copy link

mgmarlow commented Apr 27, 2023

Hello, I'm running into an issue building a native extension from bundle gem --ext=rust with the default setup. I believe I've narrowed it down to the Makefile generated by create_rust_makefile in this package.

When I compile locally on my M1 Mac, the resulting gem in bundler has this directory structure:

lib/
  my_gem.rb
  my_gem/
    my_gem.bundle
    version.rb

Note the location of my_gem.bundle, nested under lib/my_gem/.

However, when I pull my gem down in production (an x86_64 linux machine) and run bundler, I have a different folder structure:

lib/
  my_gem.rb
  my_gem.so
  my_gem/
    version.rb

Note my_gem.so is now up a directory.

This breaks my gem since the require_relative path in my_gem.rb expects the compiled binary to live in the my_gem/ directory.

My extconf.rb is the default generated by bundle gem --ext=rust:

# frozen_string_literal: true

require "mkmf"
require "rb_sys/mkmf"

create_rust_makefile("my_gem/my_gem")

And the gem entrypoint:

# frozen_string_literal: true

require_relative "my_gem/version"
require_relative "my_gem/my_gem"

module MyGem
  class Error < StandardError; end
  # Your code goes here...
end
@ianks
Copy link
Collaborator

ianks commented Apr 27, 2023

Hmm yeah that looks like a potential bug. Thanks for the excellent report, btw. Will take a look!

@ianks ianks added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Apr 27, 2023
@mgmarlow mgmarlow changed the title extconf.rb Makefile compiles binary into wrong directly dependening on OS extconf.rb Makefile compiles binary into wrong directory dependening on OS Apr 28, 2023
@mgmarlow mgmarlow changed the title extconf.rb Makefile compiles binary into wrong directory dependening on OS extconf.rb Makefile compiles binary into wrong directory depending on OS Apr 28, 2023
@ggmichaelgo
Copy link
Contributor

Hello @mgmarlow !

Can you still replicate this issue with the latest version of rb-sys?
I currently can't replicate this issue.

Does this issue happens even if you empty your tmp folder before you run rake compile?
Also, could you tell us more information about your environment, please?
What is your version of gem --version, and which version of rake-compiler are you using?

@mgmarlow
Copy link
Author

mgmarlow commented Aug 4, 2023

Ah, okay nice I think the gem version was the original issue.

  • I bumped rb-sys to 0.9.81 and published a new Ruby platform gem, but ran into the same issue on my x86_64 machine.
  • That linux machine was running a gem version of 3.3.19.
  • I bumped the linux gem version to 3.4.18.
  • After that, the *.so is installed to the proper place.

So it looks like the gem version requirement isn't just on the host machine that actually built the gem (e.g. my Mac that ran bundle exec build and pushed the gem to a registry) but also on the destination machine when it tries to build that native extension during bundle install.

I had swapped over to rake native gem awhile ago which didn't have the same issue, though I wonder if there was a gem --version difference between those two x86_64 linux machines; that is, the machine that built the native gem and pushed it to the registry, which is different from the destination machine that I've been testing against bundle install.

It is interesting that the destination machine also has a gem version requirement to run bundle install, I had thought the gem version requirement was just for using bundle gem --ext=rust and the related tooling. Is that expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants