How to build and use epgsql (erlang)

2019-09-11 12:54发布

问题:

My erlang program directory structure is below:

src
   pgtest.erl
lib
   epgsql
   rebar

I downloaded the epgsql library from https://github.com/epgsql/epgsql then tried to build it with make which gave me the below error:

make: rebar: Command not found
make: *** [compile] Error 127

So then I downloaded rebar from https://github.com/basho/rebar and build it. It was build successfully and gave me the message.

Congratulations! You now have a self-contained script called "rebar" in your current working directory. Place this script anywhere in your path and you can use rebar to build OTP-compliant apps.

So as per my understanding I copied the rebar script from the rebar directory to my epgsql directory and then tried to make again. However, I got the same error. I know I am doing it wrong, but not sure what to do?

回答1:

You can see in the epgsql Makefile[1] that is defining the command as just rebar. If it were defined as ./rebar then it would work to put it in the same directory. Since it's not, you'll need to put it somewhere in your PATH, as the output of rebar's make instructed.

Erlang projects that include rebar itself will generally specify ./rebar, while those that don't will expect it in to be located somewhere in your PATH.

[1] https://github.com/epgsql/epgsql/blob/master/Makefile#L1