Skip to content

Instantly share code, notes, and snippets.

@niku
Last active November 28, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niku/2eb451bd85e32fedb04af52b60f1d9b6 to your computer and use it in GitHub Desktop.
Save niku/2eb451bd85e32fedb04af52b60f1d9b6 to your computer and use it in GitHub Desktop.
/tmp $ git clone https://github.com/msantos/procket.git
/tmp $ cd procket/
/tmp/procket $ rebar3 compile
# The compile should be succeed
## Add new module
/tmp/procket $ echo '-module(hello).
-export([hello_world/0]).
hello_world() -> io:fwrite("hello, world\n").' > src/hello.erl
## You can't use the module with using `erl`
/tmp/procket $ erl
Erlang/OTP 22 [erts-10.5.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Eshell V10.5.6 (abort with ^G)
1> hello:hello_world().
** exception error: undefined function hello:hello_world/0
2>
## You can use the module with using `rebar3 shell`
/tmp/procket $ rebar3 shell
===> Verifying dependencies...
===> Compiling procket
/Applications/Xcode.app/Contents/Developer/usr/bin/make -f /private/tmp/procket/c_src/Makefile.ancillary
make[1]: Nothing to be done for `all'.
cc -m64 -g -Wall -o /private/tmp/procket/priv/procket -L/private/tmp/procket/c_src procket_cmd.c -lancillary
cc /private/tmp/procket/c_src/procket.o -arch x86_64 -flat_namespace -undefined suppress -shared -L/private/tmp/procket/c_src -lancillary -L /Users/niku/.asdf/installs/erlang/22.1.8/lib/erl_interface-3.13/lib -lerl_interface -lei -o /private/tmp/procket/c_src/../priv/procket.so
Erlang/OTP 22 [erts-10.5.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Eshell V10.5.6 (abort with ^G)
1> hello:hello_world().
hello, world
ok
# Create elixir app
/tmp/procket $ cd ..
/tmp $ mix new my_app
/tmp $ cd my_app
# Add dependency to mix.exs by your hand
# ...
/tmp/my_app $ grep 'deps do' -A6 mix.exs
defp deps do
[
{:procket, path: "../procket"}
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
]
end
/tmp/my_app $ iex -S mix
iex(1)> :hello.hello_world()
hello, world
:ok
@kikuyuta
Copy link

kikuyuta commented Nov 28, 2019

Thank you so much.
One of the reasons why I misunderstood is the completion of the interactive shell.

$ rebar3 shell
...snip...
Eshell V10.5.3  (abort with ^G)
1> pro^I
proc_lib          proplists         providers         providers_topo

1> pro

procket would not appear here so I thought the new module was not ready in the environment.

@kikuyuta
Copy link

I confirmed that my Elixir can call Erlang procket module. Thanks again.

@niku
Copy link
Author

niku commented Nov 28, 2019

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment