processone / fast_yaml

Fast YAML native library for Erlang / Elixir
http://ejabberd.im
Apache License 2.0
51 stars 19 forks source link

hex.pm package don't work #3

Closed benoitc closed 8 years ago

benoitc commented 8 years ago

simply including the package from hex.pm in dependencies don't work with rebar3, the nif is not correctly built and you get the following result:

able to load fast_yaml NIF: {error,
                                  {load_failed,
                                      "Failed to load NIF library: 'dlopen(/Users/benoitc/Code/barrel-platform/_build/default/rel/barrel/lib/fast_yaml-1.0.3/priv/lib/fast_yaml.so, 2): image not found'"}}

=INFO REPORT==== 22-Jun-2016::14:55:35 UTC ===
    application: fast_yaml
    exited: {{load_failed,"Failed to load NIF library: 'dlopen(/Users/benoitc/Code/barrel-platform/_build/default/rel/barrel/lib/fast_yaml-1.0.3/priv/lib/fast_yaml.so, 2): image not found'"},
             {fast_yaml_app,start,[normal,[]]}}
    type: permanent
NZSmartie commented 8 years ago

I've been following the guide https://docs.ejabberd.im/developer/elixir/ to start learning with elixir and ejabberd. I've got Erlang 1:18.3 installed with Elixir 1.3.1 (I had to downgrade from erlang 19 since ejabberd isn't ready for it yet).

Running for $ iex -S mix after successfully compiling and creating a default at config/ejabberd.yml, will throw a very similar issue

roman@home-pc:~/projects/ejabberd$ iex -S mix
Erlang/OTP 18 [erts-7.3] [source-d2a6d81] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

13:18:50.417 [info] Application lager started on node nonode@nohost
13:18:50.430 [info] Application sasl started on node nonode@nohost
13:18:50.433 [warning] unable to load fast_yaml NIF: {error,{load_failed,"Failed to load NIF library: '/home/roman/projects/ejabberd/_build/dev/lib/fast_yaml/priv/lib/fast_yaml.so: cannot open shared object file: No such file or directory'"}}
13:18:50.434 [error] CRASH REPORT Process <0.2739.0> with 0 neighbours exited with reason: {{load_failed,"Failed to load NIF library: '/home/roman/projects/ejabberd/_build/dev/lib/fast_yaml/priv/lib/fast_yaml.so: cannot open shared object file: No such file or directory'"},{fast_yaml_app,start,[normal,[]]}} in application_master:init/4 line 134
13:18:50.434 [info] Application fast_yaml exited with reason: {{load_failed,"Failed to load NIF library: '/home/roman/projects/ejabberd/_build/dev/lib/fast_yaml/priv/lib/fast_yaml.so: cannot open shared object file: No such file or directory'"},{fast_yaml_app,start,[normal,[]]}}
13:18:50.587 [critical] failed to start application 'fast_yaml': {error,
                                          {{load_failed,
                                            "Failed to load NIF library: '/home/roman/projects/ejabberd/_build/dev/lib/fast_yaml/priv/lib/fast_yaml.so: cannot open shared object file: No such file or directory'"},
                                           {fast_yaml_app,start,[normal,[]]}}}

Crash dump is being written to: erl_crash.dump...*** stack smashing detected ***: /usr/lib/erlang/erts-7.3/bin/beam terminated
                       Aborted (core dumped)

there were no warnings with fast_yaml specifically when compiled...

$ mix deps.get

roman@home-pc:~/projects/ejabberd$ mix deps.get
Running dependency resolution
* Getting lager (Hex package)
  Checking package (https://repo.hex.pm/tarballs/lager-3.0.2.tar)
  Fetched package
* Getting p1_utils (Hex package)
  Checking package (https://repo.hex.pm/tarballs/p1_utils-1.0.4.tar)
  Fetched package
* Getting cache_tab (Hex package)
  Checking package (https://repo.hex.pm/tarballs/cache_tab-1.0.3.tar)
  Fetched package
* Getting stringprep (Hex package)
  Checking package (https://repo.hex.pm/tarballs/stringprep-1.0.4.tar)
  Fetched package
* Getting fast_yaml (Hex package)
  Checking package (https://repo.hex.pm/tarballs/fast_yaml-1.0.4.tar)
  Fetched package
* Getting fast_tls (Hex package)
  Checking package (https://repo.hex.pm/tarballs/fast_tls-1.0.5.tar)
  Fetched package
* Getting fast_xml (Hex package)
  Checking package (https://repo.hex.pm/tarballs/fast_xml-1.1.13.tar)
  Fetched package
* Getting stun (Hex package)
  Checking package (https://repo.hex.pm/tarballs/stun-1.0.5.tar)
  Fetched package
* Getting esip (Hex package)
  Checking package (https://repo.hex.pm/tarballs/esip-1.0.6.tar)
  Fetched package
* Getting jiffy (Hex package)
  Checking package (https://repo.hex.pm/tarballs/jiffy-0.14.7.tar)
  Fetched package
* Getting p1_oauth2 (Hex package)
  Checking package (https://repo.hex.pm/tarballs/p1_oauth2-0.6.1.tar)
  Fetched package
* Getting p1_xmlrpc (Hex package)
  Checking package (https://repo.hex.pm/tarballs/p1_xmlrpc-1.15.1.tar)
  Fetched package
* Getting p1_mysql (Hex package)
  Checking package (https://repo.hex.pm/tarballs/p1_mysql-1.0.1.tar)
  Fetched package
* Getting p1_pgsql (Hex package)
  Checking package (https://repo.hex.pm/tarballs/p1_pgsql-1.1.0.tar)
  Fetched package
* Getting sqlite3 (Hex package)
  Checking package (https://repo.hex.pm/tarballs/sqlite3-1.1.5.tar)
  Fetched package
* Getting ezlib (Hex package)
  Checking package (https://repo.hex.pm/tarballs/ezlib-1.0.1.tar)
  Fetched package
* Getting iconv (Hex package)
  Checking package (https://repo.hex.pm/tarballs/iconv-1.0.0.tar)
  Fetched package
* Getting eredis (Hex package)
  Checking package (https://repo.hex.pm/tarballs/eredis-1.0.8.tar)
  Fetched package
* Getting exrm (Hex package)
  Checking package (https://repo.hex.pm/tarballs/exrm-1.0.6.tar)
  Fetched package
* Getting relx (Hex package)
  Checking package (https://repo.hex.pm/tarballs/relx-3.20.0.tar)
  Fetched package
* Getting providers (Hex package)
  Checking package (https://repo.hex.pm/tarballs/providers-1.6.0.tar)
  Fetched package
* Getting getopt (Hex package)
  Checking package (https://repo.hex.pm/tarballs/getopt-0.8.2.tar)
  Fetched package
* Getting erlware_commons (Hex package)
  Checking package (https://repo.hex.pm/tarballs/erlware_commons-0.21.0.tar)
  Fetched package
* Getting cf (Hex package)
  Checking package (https://repo.hex.pm/tarballs/cf-0.2.1.tar)
  Fetched package
* Getting bbmustache (Hex package)
  Checking package (https://repo.hex.pm/tarballs/bbmustache-1.0.4.tar)
  Fetched package
* Getting goldrush (Hex package)
  Checking package (https://repo.hex.pm/tarballs/goldrush-0.1.7.tar)
  Fetched package

$ mix compile

===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling p1_utils
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling cache_tab
src/cache_tab.erl:405: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.

==> eredis (compile)
Compiled src/eredis.erl
Compiled src/eredis_sub.erl
Compiled src/basho_bench_driver_eredis.erl
Compiled src/basho_bench_driver_erldis.erl
Compiled src/eredis_client.erl
Compiled src/eredis_sub_client.erl
Compiled src/eredis_parser.erl
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling p1_xmlrpc
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling p1_mysql
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling p1_pgsql
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling stringprep
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling iconv
===> Compiling getopt
===> Compiling providers
===> Compiling goldrush
===> Compiling cf
===> Compiling erlware_commons
===> Compiling bbmustache
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Rebar3 detected a lock file from a newer version. It will be loaded in compatibility mode, but important information may be missing or lost. It is recommended to upgrade Rebar3.
===> Compiling relx
==> exrm
Compiling 11 files (.ex)
Generated exrm app
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling fast_yaml
===> Compiling lager
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling p1_oauth2
WARN:  Missing plugins: [rebar_gdb_plugin]
==> jiffy (compile)
Compiled src/jiffy_utf8.erl
Compiled src/jiffy.erl
Compiling c_src/decoder.c
Compiling c_src/encoder.c
Compiling c_src/jiffy.c
Compiling c_src/utf8.c
Compiling c_src/util.c
Compiling c_src/doubles.cc
Compiling c_src/double-conversion/bignum-dtoa.cc
Compiling c_src/double-conversion/bignum.cc
Compiling c_src/double-conversion/cached-powers.cc
Compiling c_src/double-conversion/diy-fp.cc
Compiling c_src/double-conversion/double-conversion.cc
Compiling c_src/double-conversion/fast-dtoa.cc
Compiling c_src/double-conversion/fixed-dtoa.cc
Compiling c_src/double-conversion/strtod.cc
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling ezlib
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling fast_tls
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling stun
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling esip
src/esip_transaction.erl:224: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
src/esip_transaction.erl:226: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.

src/esip_codec.erl:1352: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
src/esip_codec.erl:1355: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.

src/esip.erl:754: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.

===> Compiling sqlite3
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /home/roman/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Compiling fast_xml
==> ejabberd
Compiling 136 files (.erl)
src/mod_mam_sql.erl:299: Warning: function update/5 is unused
src/mod_mam_sql.erl:318: Warning: function join/2 is unused
include/mod_offline.hrl:3: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:4: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:3: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:4: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:3: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:4: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:3: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:4: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
src/mod_roster_sql.erl:247: Warning: function record_to_string/1 is unused
src/node_flat_sql.erl:1036: Warning: function state_to_raw/2 is unused
include/mod_offline.hrl:3: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
include/mod_offline.hrl:4: Warning: erlang:now/0: Deprecated BIF. See the "Time and Time Correction in Erlang" chapter of the ERTS User's Guide for more information.
Compiling 4 files (.ex)
warning: undefined behaviour function mod_opt_type/1 (for behaviour :gen_mod)
  lib/mod_presence_demo.ex:1

warning: unused import ExUnit.Formatter.format_filters/2
  lib/ct_formatter.ex:6

Generated ejabberd app
santiagopoli commented 8 years ago

I'm facing the same issue. Compiling fast_yaml doesn't report any error but when I run the app, it throws

3:18:50.587 [critical] failed to start application 'fast_yaml': {error, {{load_failed, "Failed to load NIF library...

NZSmartie commented 8 years ago

Hey @santiagopoli,

The issue is to do with Rebar3 and has since been fixed (though not published). You'll need to grab the latest rebar.coinfig.script, replace your local copy and rebuild fast_yaml. This fix needs to be applied to fast_xml and fast_tls since they're both affect by the same issue.

mremond commented 8 years ago

It should be fixed in fast_yaml 1.0.5

york-deng commented 7 years ago

Hey @NZSmartie It seems that you have solved this issue. How to do? Whether to give us more details? Thanks!