seven_zip_ruby icon indicating copy to clipboard operation
seven_zip_ruby copied to clipboard

Locate SO_TARGET_DIR with gem rather than system

Open andrewhamon opened this issue 1 year ago • 5 comments

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 avatar Feb 02 '23 07:02 andrewhamon

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

tramuntanal avatar Feb 03 '23 14:02 tramuntanal

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

andrewhamon avatar Feb 07 '23 18:02 andrewhamon

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.

tramuntanal avatar Mar 17 '23 08:03 tramuntanal

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)

PikachuEXE avatar Jan 22 '24 02:01 PikachuEXE

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

Ph0tonic avatar Jan 29 '24 16:01 Ph0tonic