0

A google cloud functions project in java, which has worked perfectly before is suddenly all of a sudden throwing the following error

(gcloud.functions.deploy) OperationError: code=3, message=Build failed: /usr/bin/env: 'sh\r': No such file or directory; Error ID: 42fc8383

This is my deploy command

gcloud functions deploy pdf-function --entry-point de.uniba.dsg.cloudfunction.Function --runtime java11 --region europe-west3 --trigger-http --allow-unauthenticated --env-vars-file .env.yaml

There is no such environment variable named sh\r in the .env.yaml file, nor have I used it anywhere. Also this has ran without any problems previously.

EDIT: This is most likely also a git issue, but I still haven't been able to solve it. I use a windows OS. I have changed between branches in the git and since then the problem started, even though the code is unchanged. I am using gradle as the build tool.

Joy Saha
  • 11
  • 2
  • You might have edited a shell script on Windows; this is coming from a shebang with the wrong line-ending. Try running `npm install` and watch it fail. – Martin Zeitler Jan 26 '22 at 16:09
  • @MartinZeitler Do you have any idea how that might have happened or how it can be fixed? It just worked couple of days ago, and now it just doesn't. – Joy Saha Jan 27 '22 at 02:49
  • @MartinZeitler I am not facing the same problem for another project. – Joy Saha Jan 27 '22 at 03:03

1 Answers1

0

Had the same issue. Seems to be a line-ending issue as already said.

Use dos2unix for the whole source code repo and it worked for me.

find . -type f -print0 | xargs -0 dos2unix

Command is copied from here.