Ruby

From NixOS Wiki
Revision as of 08:54, 26 September 2023 by imported>IgorM (Added)

Troubleshooting

Trouble with native dependencies

Few gems will force include paths for their native dependencies in the extconf.rb describing their native dependencies.

This issue will exhibit symptoms like being unable to find dependencies that are made available through nix when building; either through bundix or simple bundler calls.

A simple fix is to fork the gem into an alternative location, apply the fix that follows, and then reference the new git repository with fix for the gem.

The fix will probably look like this (for ruby-filemagic):

diff --git a/ext/filemagic/extconf.rb b/ext/filemagic/extconf.rb
index 316e0ab979d243d03a967fda962a43b59a1bbdec..062e91d1023a3363962531fc8a54e7f0feb3bc26 100644
--- a/ext/filemagic/extconf.rb
+++ b/ext/filemagic/extconf.rb
@@ -1,15 +1,11 @@
 require 'mkmf'
 
+# gcc should be able to handle this properly.
 HEADER_DIRS = [
-  '/opt/local/include', # MacPorts
-  '/usr/local/include', # compiled from source and Homebrew
-  '/usr/include',       # system
 ]
 
+# gcc should be able to handle this properly.
 LIB_DIRS = [
-  '/opt/local/lib', # MacPorts
-  '/usr/local/lib', # compiled from source and Homebrew
-  '/usr/lib',       # system
 ]
 
 $CFLAGS << ' -Wall' if ENV['WALL']

See also