allegro/php-protobuf

--allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127.

Darkgel opened this issue · 10 comments

i run
php protoc-gen-php.php foo.proto

get this error

/data/www/php-protobuf # php protoc-gen-php.php foo.proto
': No such file or directory
--allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127.
ERROR: protoc exited with an exit status 1 when executed with:
  protoc \
    --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' \
    --allegrophp_out=':./' \
    'foo.proto'

i have installed protoc and protocbuf module

/data/www/php-protobuf # protoc --version
libprotoc 2.6.1

/data/www/php-protobuf # php -m | grep protobuf
protobuf

anyone know what should i do to solve the problem?thanks!

It seems like ' is interpreted as a file or directory. A single-quote is used to quote the protoc command arguments. You can try to narrow down a source of the problem by trying to run protoc command directly:

protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out=':./' 'foo.proto'

Which shell do you use?

It seems like ' is interpreted as a file or directory. A single-quote is used to quote the protoc command arguments. You can try to narrow down a source of the problem by trying to run protoc command directly:

protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out=':./' 'foo.proto'

Which shell do you use?

thanks for help!
i am using a centos in docker(on windows).

and i am using bash

[root@7379300f21b2 php-protobuf]# echo $0
/bin/bash

when i ran the command you suggested

[root@7379300f21b2 php-protobuf]# protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out=':./' 'foo.proto'
: No such file or directory
--allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127.

It's pretty staggering. Can you try to run command as follows (I've put away the colon passed to --allegrophp_out argument)?

protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' 'foo.proto'

It's pretty staggering. Can you try to run command as follows (I've put away the colon passed to --allegrophp_out argument)?

protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' 'foo.proto'

the same error :

[root@7379300f21b2 php-protobuf]# protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' 'foo.proto'
: No such file or directory
--allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127.

The error doesn't help much not showing which file doesn't exist 😞 Does foo.proto reside in php-protobuf directory?

It's pretty staggering. Can you try to run command as follows (I've put away the colon passed to --allegrophp_out argument)?

protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' 'foo.proto'

yes,foo.proto is under php-protobuf:

[root@7379300f21b2 php-protobuf]# ll | grep foo.proto
-rwxr-xr-x 1 root root   106 Jul 25 08:31 foo.proto
[root@7379300f21b2 php-protobuf]# cat foo.proto
message Foo
{
    required int32 bar = 1;
    optional string baz = 2;
    repeated float spam = 3;
}[root@7379300f21b2 php-protobuf]#

and i find another error when i use the absolute path of 'foo.proto':

[root@7379300f21b2 php-protobuf]# protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' '/data/www/php-protobuf/foo.proto'
/data/www/php-protobuf/foo.proto: File does not reside within any path specified using --proto_path (or -I).  You must specify a --proto_path which encompasses this file.  Note that the proto_path must be an exact prefix of the .proto file names -- protoc is too dumb to figure out when two paths (e.g. absolute and relative) are equivalent (it's harder than you think).

when i run with "--proto_path", then get the error occurred before

[root@7379300f21b2 php-protobuf]# protoc --plugin=protoc-gen-allegrophp='/data/www/php-protobuf/protoc-gen-php.php' --allegrophp_out='./' --proto_path='/data/www/php-protobuf' '/data/www/php-protobuf/foo.proto'
: No such file or directory
--allegrophp_out: protoc-gen-allegrophp: Plugin failed with status code 127.

It's not clear to me how exactly --proto_path works. Personally I've never used it.

I've run out of ideas 😞

@Darkgel ,finally I found the the way to fix the problem.
I ran the command in docker,but open the code in windows by phpstorm.If the line separator was "CRLF" of "protoc-gen-php.php" ,the error occured.When I change the line separator to "LF",I can do the compilation.