Skip to content

Locate SO_TARGET_DIR with gem rather than system#43

Open
andrewhamon wants to merge 1 commit intomasamitsu-murase:masterfrom
andrewhamon:ah/install-so-in-gem-lib
Open

Locate SO_TARGET_DIR with gem rather than system#43
andrewhamon wants to merge 1 commit intomasamitsu-murase:masterfrom
andrewhamon:ah/install-so-in-gem-lib

Conversation

@andrewhamon
Copy link

@andrewhamon andrewhamon commented Feb 2, 2023

Previously, SO_TARGET_DIR was hardcoded to install the built 7z.so into RbConfig::CONFIG["sitearchdir"], which is typically located wherever ruby is installed.

This is seems like an unusual thing for a gem to do, and breaks if ruby is installed in a read only location. It also breaks caching assumptions for some PaaS rails hosts, like Heroku.

This PR tweaks SO_TARGET_DIR so that 7z.so is instead installed in the gem directory with the rest of the seven_zib_ruby, i.e. $GEM_HOME/gems/seven_zip_ruby-1.3.0/lib which I think falls back to ~/.gem/ruby/2.7.0/gems/seven_zip_ruby-1.3.0/lib

This change allows seven_zip_ruby to build on my system, and I can also require "seven_zip_ruby" successfully. I also believe that this will not impact other users.

Fixes #41 and fixes #42

@andrewhamon andrewhamon force-pushed the ah/install-so-in-gem-lib branch from af0e3bf to 180f9bd Compare February 2, 2023 16:37
@tramuntanal
Copy link

I've deployed an app with your branch's seven_zip_ruby twice in Heroku. The first time purging the bundler cache and the second one without purging and it works.

To complete this PR it would be good to update the gem version and update the Release notes: https://github.com/masamitsu-murase/seven_zip_ruby#releases @andrewhamon

@andrewhamon
Copy link
Author

I wouldn't want to presume that @masamitsu-murase wants to cut a new release with just this commit

@tramuntanal
Copy link

It would be great to have a patch version so that apps in Heroku can be easily fixed.
I can do a PR to update the gem version and the doc once this PR is reviewed and merged.

As a temporal alternative merging this PR to master (I think it's stable), this will also ease the use of this gem.

@PikachuEXE
Copy link

I am not sure if this issue is related but I can't require seven_zip_ruby in ubuntu with ruby 3.3.0 (was ok with 3.2.2)
Error saying missing 7z.so or 7z.dll
Can provide a simplified Dockerfile example if needed (I replaced the gem with rubyzip when upgrading ruby to 3.3)

@Ph0tonic
Copy link

Hi, I thank you very for this gem and the fix, I am currently facing the same issue while installing a project using this gem.
@masamitsu-murase do you have any plan to merge this ? It would be great to be able to move forward.
Thank you very much

@inkstak
Copy link

inkstak commented Apr 29, 2025

@masamitsu-murase We have been using this branch for a year without any issue.
Any plan to release it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native gem compilation tries to mkdir in my ruby install dir Problem with native extension compilation when using a git source

5 participants