erl does not autocomplete code loaded using -pa

365 views Asked by At

This is my first couple of hours of Erlang experimentation. So be gentle, please.

  • I checked out a project (https://github.com/wooga/eredis)
  • Installed rebar
  • Compiled the modules (beam files went into ebin)
  • Fired up erl -pa ./ebin
  • Typed eredi - and hit tab

At this point nothing was displayed, whereas all other modules were auto-completed. So I (reasonably) assumed that the module beam files hadn't been loaded - lead me to all sorts of fruitless investigations of paths, etc.

But the code had been loaded, it just wasn't being auto-completed.

1> {ok,C} =  eredis:start_link().
{ok,<0.35.0>}
2> eredis:q(C,["SET","foo","bar"]).
{ok,<<"OK">>}
3> eredis:q(C,["GET","foo"]).                       
{ok,<<"bar">>}

Great, but I'd really like auto-complete to work. Is there a way to get it working? In Zsh for example, I have to execute rehash for new path items to show up - do I need to execute something similar here?

1

There are 1 answers

0
johlo On BEST ANSWER

You need to make sure the module is loaded in the shell, adding it to the path with -pa just tells the VM where to look for modules when trying to load them. There are several ways of loading a module

  • Call a function in the module that should be loaded (so after doing the eredis:start_link() call you would be able to tab-complete eredis)
  • Explicitly load the module with l(Module)
  • Programmatically: code:load_file(Module)

Load all erlang modules in path is very useful!