stephenh/ts-proto

--ts_proto_out: protoc-gen-ts_proto: The system cannot find the file specified.

dmitrijs-pavlovs-dev opened this issue ยท 9 comments

Hello i am having troubles running my script on windows.
This is the script:

SRC_DIR="./libs/proto-schema/src/proto/*.proto"
DEST_DIR="./libs/proto-schema/src/"

# node_modules/ts-proto/protoc-gen-ts_proto.cmd
protoc --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd --ts_proto_opt=outputEncodeMethods=true,useEnumNames=false,asClass=false,outputJsonMethods=true,context=true,outputNestJs=true,outputClientImpl=false --ts_proto_out=${DEST_DIR} ${SRC_DIR}

Relevant issues:
improbable-eng/ts-protoc-gen#15
#13

I tried changing the path to --plugin=protoc-gen-ts_proto=.\node_modules.bin\protoc-gen-ts_proto.cmd and also with %CD%

Does $DEST_DIR work on windows? It looks like you might be mixing unix script conventions (SRC_DIR=...) and windows conventions (.cmd).

Other than that, I don't think I can help much.

If you figure it out and find something that we should specifically highlight in our readme to help future windows users, let me know.

protoc --plugin=protoc-gen-ts_proto=%CD%/node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_opt=outputClientImpl=grpc-web --ts_proto_out=#{dir} #{dir}\#{base} -I #{dir} #{base}

%CD% -- resolve this issue
@stephenh add this in readme pls, its will help all windows users

@PhilipMantrov what is the #{dir} syntax? Is that windows shell? powershell?

@PhilipMantrov what is the #{dir} syntax? Is that windows shell? powershell?

foreach -g \"src/definitions/proto/*f.proto\" -x \"protoc --plugin=protoc-gen-ts_proto=%CD%/node_modules/.bin/protoc-gen-ts_proto.cmd --ts_proto_opt=outputClientImpl=grpc-web --ts_proto_out=./src/definitions/generated #{dir}\\#{base} -I #{dir} #{base}\"

@stephenh is foreach-cli package (https://www.npmjs.com/package/foreach-cli), i use this for listed all files in dir

Hi, please don't let this close. No matter what I do on windows the error at the top of the page is all that is printed. It seems to only happen with typescript plugins.

Please help.

Found out how to get this to work
Originally i was running the command as it was specified on the main page:

protoc -I ./proto --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd --ts_proto_out=./proto ./proto/test.proto

I finally got it to work on Windows by adding an extra \ when specifying the .cmd

protoc -I ./proto --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./proto ./proto/test.proto

Found out how to get this to work Originally i was running the command as it was specified on the main page:

protoc -I ./proto --plugin=protoc-gen-ts_proto=.\node_modules\.bin\protoc-gen-ts_proto.cmd --ts_proto_out=./proto ./proto/test.proto

I finally got it to work on Windows by adding an extra \ when specifying the .cmd

protoc -I ./proto --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./proto ./proto/test.proto

After many different attempts, this is the only thing that worked for me as well. I had to get rid of the -I arg though.

@bryding-su / @tofluid thanks for reporting what worked for you; I've linked to this issue from the home page so hopefully it's easier for Windows users to find what works for them.

wdaz commented

@tofluid thank you