Erlang escript:异常错误:右侧值不匹配{error,enoent}

时间:2014-01-17 10:09:07

标签: erlang erl

在尝试使用Windows 7(64位)上的MinGW / MSYS构建Erlang RabbitMQ插件时遇到上述错误。我正在使用Erlang v5.10.3(32位)。我可以在我的系统上运行RabbitMQ。

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)

我在pastebin上发布了完整的错误 - http://pastebin.com/S739wfhB 可以在此处找到generate_deps的完整代码 - http://pastebin.com/N4HVz8z1

聚苯乙烯。我也试过使用CYGWIN,但它返回另一个错误 - escript:无法打开文件:/ home / Fujitsu / rabbitmq / build-source / rabbitmq-public-umbrella / generate_deps

编辑1

CYGWIN返回:

$ 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.

但是,我可以使用head命令打开文件。

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)],

1 个答案:

答案 0 :(得分:1)

这很可能是因为它无法找到您尝试打开的文件,这就是POSIX enoent错误的含义。使用cygwin时更明确。 erlang badmatch错误来自第23行:

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

您尝试在{ok, Hld}上打开文件并进行匹配。但是,file:open在找不到文件时返回{error,enoent},这会导致匹配失败并生成erlang错误。

修改

我认为问题在于它正在尝试编写的文件。你被允许写在那个目录中吗?如果文件已经存在,你可以打开它进行写作吗?