benoitc / couchbeam

Apache CouchDB client in Erlang
Other
242 stars 113 forks source link

How do I get an erlang shell where I can experiment with couchbeam? #73

Closed tleyden closed 12 years ago

tleyden commented 12 years ago

I'm an erlang and couchbeam noob .. and just want to be in an erlang shell where I can experiment with couchbeam as I'm writing my own module.

Here's what I've tried:

and then:

$ erl
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.9.1  (abort with ^G)
1> application:start(sasl),
1> application:start(ibrowse),
1> application:start(couchbeam).

=PROGRESS REPORT==== 4-Sep-2012::09:18:26 ===
      supervisor: {local,sasl_safe_sup}
     started: [{pid,<0.38.0>},
           {name,alarm_handler},
           {mfargs,{alarm_handler,start_link,[]}},
           {restart_type,permanent},
           {shutdown,2000},
           {child_type,worker}]

=PROGRESS REPORT==== 4-Sep-2012::09:18:26 ===
      supervisor: {local,sasl_safe_sup}
     started: [{pid,<0.39.0>},
           {name,overload},
           {mfargs,{overload,start_link,[]}},
           {restart_type,permanent},
           {shutdown,2000},
           {child_type,worker}]

=PROGRESS REPORT==== 4-Sep-2012::09:18:26 ===
      supervisor: {local,sasl_sup}
     started: [{pid,<0.37.0>},
           {name,sasl_safe_sup},
           {mfargs,
               {supervisor,start_link,
               [{local,sasl_safe_sup},sasl,safe]}},
           {restart_type,permanent},
           {shutdown,infinity},
           {child_type,supervisor}]

=PROGRESS REPORT==== 4-Sep-2012::09:18:26 ===
      supervisor: {local,sasl_sup}
     started: [{pid,<0.40.0>},
           {name,release_handler},
           {mfargs,{release_handler,start_link,[]}},
           {restart_type,permanent},
           {shutdown,2000},
           {child_type,worker}]

=PROGRESS REPORT==== 4-Sep-2012::09:18:26 ===
     application: sasl
      started_at: nonode@nohost
{error,{not_started,crypto}}
2> Host = "localhost",
2> Port = 5984,
2> Prefix = "",
2> Options = [],
2> S = couchbeam:server_connection(Host, Port, Prefix, Options).
{server,"localhost",5984,[],[]}
3> {ok, _Version} = couchbeam:server_info(S).
** exception error: undefined function ibrowse:send_req/6
 in function  couchbeam_httpc:request/6 (src/couchbeam_httpc.erl, line 25)
 in call from couchbeam:server_info/1 (src/couchbeam.erl, line 139)

Also, not sure if it is related, but I'm not able to run "make test" either:

$ make test
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/mochiweb'
==> mochiweb (get-deps)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/mochiweb'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/jiffy'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/proper'
==> proper (get-deps)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/proper'
==> jiffy (get-deps)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/jiffy'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/oauth'
==> oauth (get-deps)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/oauth'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/ibrowse'
==> ibrowse (get-deps)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/ibrowse'
==> couchbeam (get-deps)
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/mochiweb'
==> mochiweb (compile)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/mochiweb'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/jiffy'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/proper'
==> proper (compile)
make[1]: `include/compile_flags.hrl' is up to date.
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/proper'
==> jiffy (compile)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/jiffy'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/oauth'
==> oauth (compile)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/oauth'
==> Entering directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/ibrowse'
==> ibrowse (compile)
==> Leaving directory `/Users/tleyden/Documents/work/tools/couchbeam/deps/ibrowse'
==> couchbeam (compile)
prove t/*.t
t/001-load.t ........ ok   
t/002-server.t ...... Failed 1/1 subtests 
t/003-database.t .... Failed 10/10 subtests 
t/004-document.t .... Failed 28/28 subtests 
t/005-view.t ........ Failed 5/5 subtests 
t/006-attachment.t .. Failed 13/13 subtests 

Test Summary Report
-------------------
t/002-server.t    (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: Bad plan.  You planned 1 tests but ran 0.
t/003-database.t  (Wstat: 0 Tests: 3 Failed: 3)
  Failed tests:  1-3
  Parse errors: Bad plan.  You planned 10 tests but ran 3.
t/004-document.t  (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: Bad plan.  You planned 28 tests but ran 0.
t/005-view.t      (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: Bad plan.  You planned 5 tests but ran 0.
t/006-attachment.t (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: Bad plan.  You planned 13 tests but ran 0.
Files=6, Tests=5,  1 wallclock secs ( 0.06 usr  0.02 sys +  1.24 cusr  0.23 csys =  1.55 CPU)
Result: FAIL
make: *** [test] Error 1
tleyden commented 12 years ago

I managed to get couchbeam to load in the shell via the following:

$ cd ebin
$ erl
> code:add_patha("/Users/tleyden/Documents/work/tools/couchbeam/deps/ibrowse/ebin").
> code:add_patha("/Users/tleyden/Documents/work/tools/couchbeam/deps/jiffy/ebin").
> code:add_patha("/Users/tleyden/Documents/work/tools/couchbeam/deps/mochiweb/ebin").
> code:add_patha("/Users/tleyden/Documents/work/tools/couchbeam/deps/oauth/ebin").
> code:add_patha("/Users/tleyden/Documents/work/tools/couchbeam/deps/proper/ebin").
> application:start(crypto).
> application:start(public_key).
> application:start(sasl).
> application:start(ibrowse).
> application:start(ssl).
> application:start(couchbeam).
> Host = "localhost",
> Port = 5984,
> Prefix = "",
> Options = [],
> S = couchbeam:server_connection(Host, Port, Prefix, Options).
> {ok, _Version} = couchbeam:server_info(S).

Which prints:

{ok,{[{<<"couchdb">>,<<"Welcome">>}, 
  {<<"version">>,<<"1.2.0">>}]}}

Is there an easier way to get this to work or some crucial step I'm missing?

kuloshius commented 12 years ago

The easiest way is to get rebar (https://github.com/basho/rebar) which is a neat tool for building erlang applications. Then $ cd couchbeam $ rebar get-deps (this will fetch the required dependencies for you) $ rebar compile (this will build the application) $ cd ebin $ erl 1> couchbeam:start(). (this will start couchbeam application making sure all the required dependencies are loaded.

No idea why tests fail though.

Cheers

tleyden commented 12 years ago

Great, that worked! The tests now pass too.