File not found error (resolved)

I’m trying to run our project inside linux containers emulated on Windows 10 Pro (hardware virtualization) with Docker. I need to run some script of the project, but it cannot be run because of error:

c:\plasticine>docker-compose run backend yarn generate
Starting plasticine_postgres_1 ... done
Starting plasticine_redis_1    ... done
yarn run v1.7.0
$ ./scripts/generate.sh
/bin/sh: 1: ./scripts/generate.sh: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I’ve checked the path:

c:\plasticine>docker-compose run backend ls scripts
Starting plasticine_postgres_1 ...
Starting plasticine_postgres_1 ... done
Starting plasticine_minio_1    ... done
build.sh  db  engine  generate.sh

c:\plasticine>docker-compose run backend cat /src/plasticine/backend/scripts/generate.sh
Starting plasticine_redis_1 ... done
Starting plasticine_minio_1 ... done
Starting plasticine_postgres_1 ... done
#!/bin/bash

CURRENT_DIR=$(cd `dirname $0` && pwd)
PLUGINS_DIR="$CURRENT_DIR/../plugins/"

cd $PLUGINS_DIR

printf "// Autogenerated file - DO NOT EDIT!!!\n\n" > index.js
printf "const plugins = {};\n\n" >> index.js

for dir in $PLUGINS_DIR*/; do
  if [[ -d $dir ]]; then
    dir=${dir%*/}
    dir=${dir##*/}

    printf "import $dir from './$dir';\n" >> index.js
    printf "plugins[$dir.name] = $dir.plugin;\n\n" >> index.js
  fi

What’s wrong?

I’ve found the solution. The reason was crlf, i’m using *nix container, so repository clone on windows should have the same new line characters as under linux.

git config --global core.autocrlf false

1 Like

Had to log in just to thank you for this post. I spent the last 5+ hours trying to determine why a very simple dockerfile would not run the shellscript installed when creating the image. I was pulling my hair out, only to finally find your post about newline characters after pulling from Git. That was the problem. So frustrating. Thank you.