Erlang escript: exception error: no match of right hand side value {error,enoent}‏

StackOverflow https://stackoverflow.com/questions/21183115

  •  29-09-2022
  •  | 
  •  

Question

I encountered the above error while trying to build an Erlang RabbitMQ plugin using MinGW/MSYS on Windows 7 (64 bit). I'm using Erlang v5.10.3 (32 bit). I'm able to run RabbitMQ on my system.

Fujitsu@Notebook /d/RabbitMQ/build-source/rabbitmq-public-umbrella/presence-exchange-master
$ make
[elided] generate deps
escript: exception error: no match of right hand side value {error,enoent}
  in function  generate_deps__escript__1389__793192__493000:detect_deps/5 (d:/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps, line 40)
  in call from generate_deps__escript__1389__793192__493000:'-main/1-fun-0-'/6 (d:/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps, line 19)
  in call from lists:foldl/3 (lists.erl, line 1248)
  in call from generate_deps__escript__1389__793192__493000:main/1 (d:/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps, line 17)
  in call from escript:run/2 (escript.erl, line 747)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_it/1 (init.erl, line 1054)
  in call from init:start_em/1 (init.erl, line 1034)

I've posted the full error on pastebin - http://pastebin.com/S739wfhB The complete code for generate_deps can be found here - http://pastebin.com/N4HVz8z1

Ps. I've also tried using CYGWIN but it returns another error - escript: Failed to open file: /home/Fujitsu/rabbitmq/build-source/rabbitmq-public-umbrella/generate_deps

EDIT 1

CYGWIN returns:

$ make
[elided] generate deps
escript: Failed to open file: /cygdrive/d/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps
[elided] generate deps
escript: Failed to open file: /cygdrive/d/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps
make: *** No rule to make target 'build/deps.mk', needed by 'ebin/presence_exchange.beam'.  Stop.

However, I'm able to open the file using the head command.

Fujitsu@Notebook /cygdrive/d/RabbitMQ/build-source/rabbitmq-public-umbrella/presence-exchange-master
$ head /cygdrive/d/RabbitMQ/build-source/rabbitmq-public-umbrella/generate_deps
#!/usr/bin/env escript
%% -*- erlang -*-
-mode(compile).

%% We expect the list of Erlang source and header files to arrive on
%% stdin, with the entries colon-separated.
main([TargetFile, EbinDir]) ->
    ErlsAndHrls = [ string:strip(S,left) ||
                      S <- string:tokens(io:get_line(""), ":\n")],
    ErlFiles = [F || F <- ErlsAndHrls, lists:suffix(".erl", F)],

No correct solution

OTHER TIPS

Most likely this is because it cant find the file you are trying to open, this is what the POSIX enoent error means. It is even more explicit when you used cygwin. The erlang badmatch error comes from line 23:

{ok, Hdl} = file:open(TargetFile, [write, delayed_write]),

where you try to open the file and match on {ok, Hld}. However file:open returns {error,enoent} when can't find the file, which causes the match to fail and generate the erlang error.

EDIT:

As I see it the problem is the file it is trying to write. Are you allowed to write in that directory? If the file already exists are you allowed to open it for writing?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top