Fix FFI configuration for Homebrew on macOS#11
Open
skull-squadron wants to merge 1 commit into
Open
Conversation
While it appears to work for brew installed to platform-variable default location that requires `sudo` to taint a machine, it doesn't work with alternate locations where `HOMEBREW_PREFIX` is set. This is a show-stopping failure.
f91c330 to
672fa2c
Compare
Owner
|
@skull-squadron thx for the patch. I'm a bit on the fence whether I should merge it. On one hand, I see that this is a known limitation of the ffi gem (I see you commented there as well). On the other hand, I also understand that the ugliness of remove-add const here is necessary due to the original array being frozen. I wonder what others do. Do you by chance know of other gems which require FFI on mac that you can reference as using this type of workaround? |
| lib = ::File.join(prefix, "lib") | ||
| unless (orig_value = ::FFI::DynamicLibrary::SEARCH_PATH).include?(lib) | ||
| ::FFI::DynamicLibrary.send(:remove_const, :SEARCH_PATH) # Necessary to avoid redefinition warning. | ||
| ::FFI::DynamicLibrary::SEARCH_PATH = orig_value.dup.unshift(lib).freeze |
Owner
There was a problem hiding this comment.
lib must also be frozen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While it appears to work for brew installed to platform-variable default location that requires
sudoto taint a machine, it doesn't work with alternate locations whereHOMEBREW_PREFIXis set. This is a show-stopping failure.