erlangrebarrebar3

How to set proxy in Erlang escript?


When I am about to install rebar3 on Windows7, I've cloned the code from github, and then use git bash to install it. But when I type in the command, It shows that `escript: exception error: no match of right hand side value:

{error, {malformed_url,xxxx_username,"passwd@proxy.com:8080"}}

I am in China and I am work in a company that block my net. But I've got a proxy, so how can I set proxy in escript or this case to solve my problem?


Solution

  • escript is just some erlang code, and the no match error happens when something on the right hand side of an equals sign (which is the match operator in erlang) does not match what is on the left hand side of the equals sign. Here's a simple example:

    1> X = 20.
    20
    
    2> 3 = X.
    ** exception error: no match of right hand side value 20
    

    Because 3 does not match the value of X, i.e. 20, you get a match error followed by whatever the right hand side value is, which in this case is 20.

    In your case, the right hand side value is the tuple you posted, which is obviously an error returned by whatever expression was on the right hand side of the equals sign in question. For instance:

    3> {ok, file} = file:open("non-existent", read).
    ** exception error: no match of right hand side value {error,enoent}
    

    In the example, file:open() returned a tuple starting with the atom error:

    {error, enoent}
    

    which can never match a tuple on the left hand side of an equals sign that starts with the atom ok:

    {ok, file}
    

    Something in the escript code you ran created a malformed_url.