Skip to content

Fix FFI configuration for Homebrew on macOS#11

Open
skull-squadron wants to merge 1 commit into
HoneyryderChuck:masterfrom
skull-squadron:patch-2
Open

Fix FFI configuration for Homebrew on macOS#11
skull-squadron wants to merge 1 commit into
HoneyryderChuck:masterfrom
skull-squadron:patch-2

Conversation

@skull-squadron

Copy link
Copy Markdown
Contributor

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.

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.
@HoneyryderChuck

Copy link
Copy Markdown
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?

Comment thread lib/idnx/idn2.rb
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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib must also be frozen.

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.

2 participants