error in the text of the book ?

29 views
Skip to first unread message

Roelof Wobben

unread,
Feb 10, 2015, 10:49:18 AM2/10/15
to nitro...@googlegroups.com
Hello Jesse,


At page 46 I have to go to the site/ebin directory and open a erl prompt.
And then do rr(visitors_db).

But I see then this output:

rr(visitors_db).                                                                                                                                                                    
{error,nofile}

Which is allright because earlier you said that the visitors_db.erl file must be made at site/src and not in site/src/ebin

Roelof

Daniel Hallin Widgren

unread,
Feb 10, 2015, 11:28:39 AM2/10/15
to nitro...@googlegroups.com

Have you compiled the code?

--
You received this message because you are subscribed to the Google Groups "Nitrogen Project / The Nitrogen Web Framework for Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nitrogenweb...@googlegroups.com.
To post to this group, send email to nitro...@googlegroups.com.
Visit this group at http://groups.google.com/group/nitrogenweb.
For more options, visit https://groups.google.com/d/optout.

Roelof Wobben

unread,
Feb 10, 2015, 11:33:06 AM2/10/15
to nitro...@googlegroups.com
Compiled it ? The book is not talking about compiling.
I use sync:go() and see no errors ?

Roelof

Op dinsdag 10 februari 2015 17:28:39 UTC+1 schreef Daniel Widgren:

ll...@writersglen.com

unread,
Feb 10, 2015, 12:47:03 PM2/10/15
to nitro...@googlegroups.com, nitro...@googlegroups.com

Hi Roelof,

 

Yes, there may be a slight ambiguity in the text. No doubt there are many more. But with help of readers like you we'll dig 'em out.

 

As noted in Erlang erl docs, erl -pa ebin simply puts the ebin directory in the code path so it can be found when you compile the system:

 

-pa Dir1 Dir2 ...

Adds the specified directories to the beginning of the code path, similar to code:add_pathsa/1. See code(3). As an alternative to -pa, if several directories are to be prepended to the code and the directories have a common parent directory, that parent directory could be specified in the ERL_LIBS environment variable. See code(3).

 

http://erlang.org/doc/man/erl.html

 

In other words, -pa Dir...  does not open a new directory. If you look more carefully at the commands at the bottom of page 45, you'll see:

 

~/nb/site/include$ cd ../site
~/nb/site/$ erl -pa ebin

 

This sequence moved you from the include directory to the site directory. The erl -pa ebin simply puts ebin in the code path. Thus, if you follow the sequence you're executing rr(visitors_db) out of the site directory, in which case rr(visitors_db) should return as expected.

 

Many thanks for reading our book. We're working hard to post more content soon.

 

All the best,

 

Lloyd 

Roelof Wobben

unread,
Feb 10, 2015, 1:30:17 PM2/10/15
to nitro...@googlegroups.com
Still there is something not well in the explanation.

I went to the src/include dir and did this :

action@intense-tachyon-23-192720:~/workspace/nb/site/include$ cd ../site                                                                                                               
-bash: cd: ../site: No such file or directory  


I think you mean go back one to the nb/site directory.
So I did that and see this output.

action@intense-tachyon-23-192720:~/workspace/nb/site$ erl -pa erl                                                                                                                      
Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:7] [async-threads:10] [hipe] [kernel-poll:false]                                                                                     
                                                                                                                                                                                       
Eshell V6.0  (abort with ^G)                                                                                                                                                           
1> rr(visitors).                                                                                                                                                                       
{error,nofile}                                                                                                                                                                         
2>         

which is right because it's in the site/src directory.

Roelof



Op dinsdag 10 februari 2015 18:47:03 UTC+1 schreef LRP:

ll...@writersglen.com

unread,
Feb 10, 2015, 4:03:15 PM2/10/15
to nitro...@googlegroups.com, nitro...@googlegroups.com

Hi Roelof,

 

Your directory structure should look like this;

 

nb

...site

......ebin

......include

......src

......static

......templates

 

Assuming you have the correct directory structure and you are in the nb/site/include directory...

 

nb/site/include$ cd ../site

 

... should bring you up one level in the directory hierarchy, e.g. to nb/site.

 

Also note: it's...

 

nb/site$ erl -pa ebin   % NOTE ebin not erl

 

Best wishes,

Roelof Wobben

unread,
Feb 11, 2015, 10:57:46 AM2/11/15
to nitro...@googlegroups.com
Thanks,

I verified that I did everything right but still I do not work.

I have made a screenshot where you can see all the steps.
The screenshot can be found here : http://imgbin.org/index.php?page=image&id=22300

Roelof


Op dinsdag 10 februari 2015 22:03:15 UTC+1 schreef LRP:

Jesse Gumm

unread,
Feb 11, 2015, 11:02:29 AM2/11/15
to nitrogenweb
Thanks for the report.

We'll need to make it more explicit in the text.

Basically, the module will need to be compiled (as Daniel mentioned).
If sync is running (sync:go()) when the file is edited, then it should
properly compile the new file. On the other hand, if either sync or
the VM itself isn't running, you'll want to compile the file, the
simplest way is to run `make` from the root of your project.

Then you can do rr(visitors_db).

-Jesse
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Roelof Wobben

unread,
Feb 11, 2015, 11:28:44 AM2/11/15
to nitro...@googlegroups.com
I think I found the culprit.

My visitors_db.erl looks like this :

-module(visitors_db).
-compile(export_all).
-include("nb.hrl").

But as soon as I do make in the root directory I see this error message :

==> site (compile)                                                                                                                                                                     
Compiling /home/action/workspace/nb/site/src/visitors_db.erl failed:                                                                                                                   
/home/action/workspace/nb/site/include/nb.hrl:1: syntax error before:                                                                                                                  
ERROR: compile failed while processing /home/action/workspace/nb/site: rebar_abort                                                                                                     
make: *** [compile] Error 1  


Roelof


Op woensdag 11 februari 2015 17:02:29 UTC+1 schreef Jesse Gumm:

Jesse Gumm

unread,
Feb 11, 2015, 11:30:43 AM2/11/15
to nitrogenweb
So there's a syntax error inside nb.hrl at line 1.

What is in your nb.hrl file?

Roelof Wobben

unread,
Feb 11, 2015, 11:41:47 AM2/11/15
to nitro...@googlegroups.com
-record(visitor, {date, time, name, company})

Roelof


Op woensdag 11 februari 2015 17:30:43 UTC+1 schreef Jesse Gumm:

Jesse Gumm

unread,
Feb 11, 2015, 11:43:23 AM2/11/15
to nitrogenweb
Ah HA! There it is.

Looks like you're just missing the period at the end of the definition.

-record(visitor, {date, time, name, company}).

Give that a shot.

Roelof Wobben

unread,
Feb 11, 2015, 11:45:28 AM2/11/15
to nitro...@googlegroups.com
Thanks, finnaly solved.

Roelof


Op woensdag 11 februari 2015 17:43:23 UTC+1 schreef Jesse Gumm:
Reply all
Reply to author
Forward
0 new messages