3

How can I install Yaws as a Rebar dependency in my Erlang application?

Thanks,

LRP

Lloyd R. Prentice
  • 4,329
  • 3
  • 21
  • 31

1 Answers1

4

First, make sure you're using a recent version of rebar, say from April 2012 or later (rebar commit dc472b or later), as changes to it were made in early 2012 specifically to support projects like Yaws.

To use Yaws as a dependency, specify the following in your rebar.config file:

{deps, [{yaws, ".*", {git, "git://github.com/klacke/yaws", {branch, "master"}}}]}.

You can replace the {branch, "master"} part with a specific Yaws tag if you like:

{deps, [{yaws, ".*", {git, "git://github.com/klacke/yaws", {tag, "yaws-1.94"}}}]}.

Note, though, that I don't recommend using a version lower than Yaws 1.94 due to changes made to Yaws specifically for rebar build support.

How you actually run Yaws depends on how your app uses it. Using it in an embedded fashion is probably best for rebar-built apps, since that way you won't have any dependencies on yaws.conf files. But if you want to run Yaws as a stand-alone web server, you can build your dependencies and your application and then run Yaws interactively like this:

rebar get-deps compile
./deps/yaws/bin/yaws -i -pa ebin

This uses the default yaws.conf file found in ./deps/yaws/etc/yaws/yaws.conf, which you can modify as needed. Starting Yaws in this fashion won't include the ebin directories of any other of your application's rebar dependencies in the load path, but you can either add the necessary paths using additional -pa options to Yaws, or by specifying them in the yaws.conf file.

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
  • Being rather spoiled with the automatics of rebar lately, I want to make use embedded yaws , so I added the requirement of yaws-1.99 to rebar config. There are a lot of strange complaints, for example, duplicate .src file. Also, do I need to do further magic inside the deps/yaws dir, for example getting complaints like "Can't exec "libtoolize": No such file or directory at /usr/bin/autoreconf line 196." – mattias Jan 18 '15 at 12:11
  • @mattias: are you trying to run `make` to build Yaws? Yaws supports both autotools and rebar, but there's no `make` target for rebar. You need to run `rebar compile` directly to build Yaws with rebar. – Steve Vinoski Jan 18 '15 at 15:57
  • My initial first attempt was just to add the yaws ref to my rebar.config and run rebar get-deps. That didn't work for me. Then I tried some other ways. Should it have been so simple? – mattias Jan 18 '15 at 16:33
  • Yes, it should be that simple. Just to be sure, I just set up a simple application with Yaws as a dep, ran `rebar get-deps compile`, and it downloaded `yaws-1.99` and built it, no problem. Running `rebar --version` shows `rebar 2.5.1 R14B04 20141216_212600 git 2.5.1-57-gb796065`. This is specifically built from git version `b796065` from early Dec 2014 because currently (as of 18 Jan 2015) versions newer than that don't work with Yaws. – Steve Vinoski Jan 18 '15 at 17:20
  • Ok, I will try with that version of rebar, I have tried with an old 2.0.?? version and "rebar 2.5.1 17 20150118_115522 git 2.5.1-102-g25aca7e ". Good to hear that it should be that simple. – mattias Jan 18 '15 at 19:25
  • Yes, with that particular version of rebar, I can compile yaws 1.99 – mattias Feb 02 '15 at 19:22
  • Great! Note also that `rebar` master at github as of commit 930d2c7 (from 25 Jan 2015) has fixed the bug I alluded to in my earlier comment. – Steve Vinoski Feb 02 '15 at 19:32