[erlang-questions] Rebar & Cowboy on Windows 7

Loïc Hoguin essen@REDACTED
Mon Oct 8 18:07:26 CEST 2012


Hello,

On 10/08/2012 05:54 PM, David Mercer wrote:
> 3.I downloaded Cowboy from Git Hub the same way I did Rebar.  The
> resulting directory was again named “extend-cowboy-1f9d71c” in the
> nonstandard way of Git Hub, but it still works.

Note that you typically just include Cowboy as a dependency for your own 
application.

> 4.Here I ran into some problems, but it turned out they were mine rather
> than Windows’s.  I tried a “rebar compile” on Cowboy, but got an error
> about the dependency on Ranch not being available.  It should have been
> available, since I had previously downloaded it, and even if I hadn’t,
> the /rebar.config/ told it where it could get it from.  Turns out,
> however, that I have to explicitly tell it to get dependencies.  Tuncer
> Ayaz – bless his soul – gave me a hand here and explained that I should
> use the command “rebar get-deps”, “rebar get-deps compile”, or
> abbreviated to “rebar g-d com”.  With that, it downloaded Ranch and
> compiled fine.  Yay!

It's automated on Linux because of the Makefile, you can just type 
"make" there. Not sure the same can be done for Windows without a lot of 
manipulations.

> 5.Interestingly enough, Rebar does not download the dependencies into
> the Erlang lib directory, but rather into a “deps” subdirectory of your
> application.  This means /erl.exe/ and /werl.exe/ cannot see it, but
> this can easily be rectified by either copying the downloaded
> applications up into the lib directory, or using the “-pa” option on the
> command line.  If anyone has any suggestions as to which is better for
> their workflow, please let me know.

Neither, the proper way is building your own releases. Releases will 
then include both erl.exe and Cowboy and all the applications required.

The examples use -pa only for demonstration purposes, I recommend 
building releases even while developing.

> 6.At this point, Cowboy was working, but I figured I should try to get
> it to do something useful.  I couldn’t find a whole lot of documentation
> on its API, but I did find that it came with a few examples in the
> /examples/ subdirectory.  I decided to give the static example a whirl,
> and Rebarred it and then ran it, and it worked.  Fine.  Out of the box.
> Yay!

Can you try "rebar edoc"? It's supposed to generate the API reference.

> 7.Unfortunately, when it served up the /test.txt/ sample file, Chrome
> treated it as a download rather than text to be displayed in the
> browser.  Usually when I encounter an issue where I want to see what’s
> coming down the wire, I just telnet to the appropriate port and send a
> “GET /” to see what is returned.  I don’t think Cowboy handles HTTP 1.0,
> though I couldn’t find any record of that.  At any rate, I just had to
> do some extra typing in order to send a minimal HTTP 1.1 request, and
> after some poking around, I discovered my problem was related to the
> MIME type being sent in the HTTP response.  So I added the “mimetypes”
> application to the example’s Rebar dependencies, modified the
> /static_app.erl/ file to use the function /mimetypes:path_to_mimes/ to
> choose the correct MIME type and then restarted it – or at least tried
> to.  Try as I may, I could not get it to work for the longest time.  In
> the end, I determined that mimetypes’s lexer was built for Unix only,
> not Windows, so it was not recognizing the line endings in the provided
> /mime.types/ file.  The solution then was to modify mimetypes’s
> /mimetypes_scan.xrl/ to recognize a CRLF as a newline, too.  I suppose I
> should figure out how to use Git Hub so I can submit that patch.  At any
> rate, now it all works like champ.

Please do send a patch, that'd be much appreciated!

And yeah the example can probably be improved a little using the 
mimetypes application. Feel free to send a patch for that, too.

> So I can confirm that both Rebar and Cowboy work on Windows 7 system.
> Thank-you all for your work on these.

Thanks for testing!

-- 
Loïc Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu



More information about the erlang-questions mailing list