Running :jiffy: Failed to find library init function

I’ve installed jiffy version 1.1.1 – it installed fine, but I’m not able to actually run it. I tried this:

iex> :jiffy.decode("{\"foo\": \"bar\"}")

12:33:39.643 [warning] The on_load function for module jiffy returned:
{:error,
 {:bad_lib,
  'Failed to find library init function: \'dlsym(0xa802c090, _nif_init): symbol not found\''}}

** (UndefinedFunctionError) function :jiffy.decode/1 is undefined (module :jiffy is not available)
    (jiffy 1.1.1) :jiffy.decode("{\"foo\": \"bar\"}")

or

13:48:30.985 [warning] The on_load function for module jiffy returned:
{:error,
 {:load_failed,
  'Failed to load NIF library: \'dlopen(/path/to/my/_build/dev/lib/jiffy/priv/jiffy.so, 0x0002): symbol not found in flat namespace \'__ZN17double_conversion6Bignum12AssignUInt64Ey\'\''}}

I seem to have missed some fundamental installation step, but I didn’t spot anything in the README. Anyone have experience with this?

elixir          1.14.2
erlang          24.2

I have no idea what’s going on, but I found a Github issue that’s complaining about a function with a name like the one in the error message:

The relevant library appears to be libdouble-conversion. Jiffy has a copy vendored inside its c_src directory:

For things like this, you’ll definitely want to post more details about your setup (OS version, compiler versions, etc) because the issue is below the BEAM level.

Thanks Matt – I haven’t gotten into NIFs before, so this is enlightening.

I’m on an Apple M1 Pro chip running OS Ventura 13.1

❯ gcc --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
❯ make --version
GNU Make 3.81
This program built for i386-apple-darwin11.3.0

I’m trying out Jsonrs too…

I’m still an M1 noob, but my experience so far is that mixing i386 and arm64 tools is going to result in a Bad Time. I’m not sure if that applies to programs like make tho. :thinking:

1 Like

Make sure your shell and tools are all ARM64 i.e. compiled for M1.

I think make came with XCode, but that i386 does look suspicious. I’m wary of removing it because it’s so fundamental to things, but I suppose I should give that a try…

I’d strongly advise against removing anything from the XCode bundle as other parts may depend on it. Installing a different version (via brew, for instance) in a directory that’s earlier in $PATH is the safer choice.

1 Like

Wise words. Thanks for the tip!