Getting Started with Erlang and Nitrogen

Getting Started with Erlang and Nitrogen

Introduction

As I had yet another idea for a startup, I fired up Visual Studio and started implementing a small demo...

Flexing my idea muscle; trying to build a POC for another startup idea #startup10 #ElliottWavetwitter.com/ToJans/status/…

— Tom * suǝssuɐſ (@ToJans)  September 6, 2012

However, the main feature that would elevate my example requires a lot of interaction, and quite frankly, interaction is a pain in web apps IMO, as there is still a mental shift between frontend and backend. For this particular thing I needed the distance to be as small as possible, so I started searching and found Erlang...

One more last video before I go to bed vimeo.com/8258045 #erlang #nitrogen #riak

— Tom * suǝssuɐſ (@ToJans)  September 12, 2012

I will not go into the details why this looks like a perfect match, because I would like to build an MVP first, but I can tell you that it resembles the bee's knees at this current moment to me... So how do I get started? This is a walkthrough where I will post my progress... This post will evolve as I manage to get further....

Installation

Well, I still work on windows, so I downloaded the binary erlang package from here:  https://www.erlang-solutions.com/downloads/download-erlang-otp

I downloaded the win x64 binary and ran it, as simple as that; mission #1 accomplished; a few more to go.

The Web Framework

Well, I decided to go for nitrogen, as it looks pretty neat IMO, so I created a nitrogen folder and downloaded the windows package from  http://nitrogenproject.com/downloads  and unzipped it.

#2 accomplished

Hello world 

I copied the whole nitrogen package to a new folder called HelloWorld - how original - opened a cmd window in the folder, and this is what I typed and the result..

So I opened up Windows explorer and checked... Aha!

I copied the bin path, went back to my hello-world folder, right-clicked start.cmd and chose for edit, and assumed replacing 5.7.5 (the Erlang version in the nitrogen package) with 5.9.2 would be enough, but then I noticed: there is also and erts-5.7.5 subfolderfolder in the hello world project, which looks like it contains the whole erlang version...

So I decided to look a bit closer...

When running the commands from the batch file manually with the installed erlang  (i.e. the one from c:\program files) I get a crash on the execution of the last line, so it compiles, but refuses to run. So I decide to uninstall erlang, as I assume it is some kind of a version conflict, and I probably do not need the installation anyway.

So I removed the installed Erlang, and also found out I had another (32-bit) version installed, so I removed that one as well...

However, when I try to compile using the following statement I still get an error:

C:\blah\nitrogen\helloworld>"erts-5.7.5\bin\erl.exe" -pa %PA% -make
Could not load module C:\Program Files\erl5.7.5\erts-5.7.5\bin\erlexec.dll.

So I decided to go looking for erlang 5.7.5 for windows.... But then it hit me; google to the rescue: https://groups.google.com/forum/?fromgroups=#!topic/nitrogenweb/0vXvXwLvBOM

So I should probably reinstall the Erlang binaries I first installed and try to build nitrogen myself...

Let's try again....

Ok, installed the initial erlang version again (had to kill an apparently still running erlang proces).

Now I went looking into a nitrogen tutorial ( http://nitrogenproject.com/doc/tutorial.html ) and pulled in thenitrogen source code from github .

I browsed a bit further in the git project, and found this document mentioned on the readme: "Compiling Nitrogen on Windows"... There they advise to install Erlang for win R15B02 for windows and install it in the folder "c:\erl5.9 ", so I installed yet another erlang (5.9.2), but now in the recommended folder, and tried running nitrogen again; here's what happened:

As it still does not work, I assume it is time to try and compile the thing...

So I add  c:\erl5.9\bin to the path in my environment settings.

Now I install msysgit using the netinstaller , not the regular one , and install into the default  c:\msysgit

You need to use this version, as this downloads the source for git and enables you with a complete mingw build environment, which allows you to build the nitrogen source code as well...

Building git apparently seems to take a few minutes...

... And some more...

And we're finally there!!! 

Now time to clean up the folders and pull in the sourcecode and build it...

And we fail again... 

So I am now digging into the rebar mailing lists: http://lists.basho.com/pipermail/rebar_lists.basho.com/2011-September/001074.html

Aha, found it; I simply have to make sure c:\msysgit\bin is contained in the PATH environment variable; it now fetches all dependencies....

Crap... Now I get a compile error in nitrogen itself...

So I checked to see if there was any Erlang feedback available on twitter...

Well, the live blogging experiment is certainly a challenge: still not able to run nitrogen on windows #erlang#help corebvba.be/blog/post/Live…

— Tom * suǝssuɐſ (@ToJans)  September 13, 2012

In the mean time I'll start looking at the source over at github; maybe I have a stable branch or similar...

Aha, I found an open issue regarding the mimetypes library on github, but apparently there's not a lot of response there....  https://github.com/spawngrid/mimetypes/issues/10

Currently in the process of digging in the source code of the mimetypes lib, and I also received a good tip from Neil:

tojans top tip - buy a mac :)

— Neil Robbins (@NeilRobbins)  September 13, 2012

Ok; I took a small break; looks like the problem is actually in the post_compile script for the mimetypes; currently debugging erlang script!!! 

My understanding of erlang is growing slowly  Cool ... Looks like this file just extracts all method definitions, since these have not changed, there is no need to change it, so I just commented the whole enchilada (gist here: https://gist.github.com/3714046 ) et voila, it compiles!

AAAAAAAAAAAAAAAAAAAAARGH ! 

Still no go; I'll call it a day for today, as I have some other stuff to do as well, and this took way longer then I hoped.... Laters!

Put the Live Blog on hold, as it took to much of my time already... To be continued #erlang #nitrogencorebvba.be/blog/post/Live…

— Tom * suǝssuɐſ (@ToJans)  September 13, 2012

<script src="http://www.codeproject.com/platform.twitter.com/widgets.js"></script>

I'm back

A new day, new ideas, so I started looking at the google groups, and apparently I'm not the first one having this problem:  http://groups.google.com/d/msg/nitrogenweb/KoBJCXr5SEI/UhgkWWTp09wJ .

So let us try that....

Uninstalled all erlang..

Removed original folder

Now downloading and installing windows release from  http://www.erlang.org/download_release/6  in "C:\Program Files\erl5.7.5", not the (x86) folder.

Double click start.cmd in the nitrogen folder, it should open up the erlang console. surf to http://localhost:8000 et voila !!! FINALLY !!!

Finally

I wrote a small follow-up post .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值