clojure-protobuf - 无法运行程序[path protoc](在目录“resources / proto”中):error = 2,没有这样的文件或目录

时间:2015-04-12 15:44:47

标签: clojure protocol-buffers

我正在尝试使用clojure-protobuf,但是当我运行lein protobuf时我得到了这个错误:

 >  /Users/elf/.lein/cache/lein-protobuf/protobuf-2.3.0/src/protoc google/protobuf/descriptor.proto --java_out=/Users/elf/.lein/cache/lein-protobuf/protobuf-2.3.0/java/src/main/java -I. -I/Users/elf/workspace/tmp/protobuf/target/proto -I/Users/elf/workspace/tmp/protobuf/resources/proto
java.io.IOException: Cannot run program "/Users/elf/.lein/cache/lein-protobuf/protobuf-2.3.0/src/protoc" (in directory "resources/proto"): error=2, No such file or directory
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
    at conch.core$proc.doInvoke(core.clj:27)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:617)
    at leiningen.protobuf$compile_protobuf.invoke(protobuf.clj:127)
    at leiningen.protobuf$compile_google_protobuf.invoke(protobuf.clj:145)
    at leiningen.protobuf$compile.doInvoke(protobuf.clj:154)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.protobuf$compile.invoke(protobuf.clj:150)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.protobuf$protobuf.doInvoke(protobuf.clj:166)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.Var.invoke(Var.java:415)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$resolve_task$fn__3029.doInvoke(main.clj:189)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.RestFn.applyTo(RestFn.java:132)
    at clojure.lang.AFunction$1.doInvoke(AFunction.java:29)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:619)
    at leiningen.core.main$apply_task.invoke(main.clj:230)
    at leiningen.core.main$resolve_and_apply.invoke(main.clj:234)
    at leiningen.core.main$_main$fn__3092.invoke(main.clj:303)
    at leiningen.core.main$_main.doInvoke(main.clj:290)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.lang.Var.invoke(Var.java:415)
    at clojure.lang.AFn.applyToHelper(AFn.java:161)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.core$apply.invoke(core.clj:617)
    at clojure.main$main_opt.invoke(main.clj:335)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:436)
    at clojure.lang.Var.invoke(Var.java:423)
    at clojure.lang.AFn.applyToHelper(AFn.java:167)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
Caused by: java.io.IOException: error=2, No such file or directory
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 48 more
in /Users/elf/workspace/tmp/protobuf 

我的project.clj

(defproject protocolbuf-test "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.flatland/protobuf "0.7.1"]
                 [aleph "0.4.0-beta3"]
                 [lamina "0.5.6"]
                 [gloss "0.2.4"]]

  :plugins [[lein-protobuf "0.4.2"]])

和我的原型文件:

message Log {
                required int32 id = 1;
                required string event = 2;
}

感谢您提供任何帮助。

1 个答案:

答案 0 :(得分:2)

我的问题是没有安装automake-1.14。我安装了automake-1.15,但这还不够。要重现此问题,我转到~/.lein/cache/lein-protobuf/protobuf-2.6.1并运行./configure && make并显示错误:

 cd . && /bin/sh /Users/me/.lein/cache/lein-protobuf/protobuf-2.6.1/missing automake-1.14 --foreign
/Users/me/.lein/cache/lein-protobuf/protobuf-2.6.1/missing: line 81: automake-1.14: command not found
WARNING: 'automake-1.14' is missing on your system.
         You should only need it if you modified 'Makefile.am' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'automake' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>
make: *** [Makefile.in] Error 1

我安装了automake-1.14:

# Automake
echo "Installing automake-1.14 ..."
curl -fL https://ftpmirror.gnu.org/automake/automake-1.14.tar.gz | tar xzf -
cd automake-*
./configure --prefix=/usr/local
make && sudo make install
[ $? -eq 0 ] && AUTOMAKE_ERROR=0 && cd .. && rm -rf automake-*

来自https://gist.github.com/jellybeansoup/4192307#gistcomment-1676007