nebari-dev / nebari-docker-images

📦 Ready to use Docker images maintained by the Nebari team
BSD 3-Clause "New" or "Revised" License
6 stars 13 forks source link

[BUG] - Docker build fails due to `/usr/bin/env: 'bash\r': No such file or directory error in install-apt-minimal.sh` script #166

Closed arjxn-py closed 2 months ago

arjxn-py commented 3 months ago

Describe the bug

When attempting to build a Docker image using Dockerfile.jupyterlab, the build process fails with the error /usr/bin/env: 'bash\r': No such file or directory. This issue appears to be related to the presence of Windows-style line endings (\r\n) in the install-apt-minimal.sh script.

Expected behavior

The Docker image should build successfully without encountering errors related to line endings.

Actual Behavior

The build fails with the following error message:

 => ERROR [ 3/13] RUN /opt/scripts/install-apt-minimal.sh                                                                                                                    0.2s 
------
 > [ 3/13] RUN /opt/scripts/install-apt-minimal.sh:
0.202 /usr/bin/env: 'bash\r': No such file or directory
------
Dockerfile.jupyterhub:13
--------------------
  11 |
  12 |     COPY scripts/install-apt-minimal.sh /opt/scripts/install-apt-minimal.sh
  13 | >>> RUN /opt/scripts/install-apt-minimal.sh
  14 |
  15 |     COPY scripts/fix-permissions /opt/scripts/fix-permissions
--------------------
ERROR: failed to solve: process "/bin/sh -c /opt/scripts/install-apt-minimal.sh" did not complete successfully: exit code: 127

How to Reproduce the problem?

Run the following command from the root directory:

docker build -f Dockerfile.jupyterlab -t nebari-jupyterlab:latest .

Command output

No response

Versions and dependencies used.

conda 24.4.0 OS - Windows 11 & Ubuntu 22.04

Anything else?

The issue is caused by Windows-style line endings (\r\n) in the install-apt-minimal.sh script. Converting the line endings to Unix-style (\n) resolves the problem.

arjxn-py commented 3 months ago

I was trying to build the docker image after bumping jupyter-scheduler >=2.7.0 in jupyterlab/environment.yaml that is related to nebari-dev/nebari#2548, using dos2unix scripts/install-apt-minimal.sh solved this error for me. I'd be happy to try fix it upstream as well if perrmitted.

Adam-D-Lewis commented 2 months ago

@arjxn-py When you check out a repo using git on windows, I believe it converts line endings by default from \n on linux to \r\n on windows if you have the autcrlf setting set to true. That sounds like what is happening to you. You can check if you have that option set by git config --list

arjxn-py commented 2 months ago

Yes @Adam-D-Lewis, seems like this was the case only, I just confirmed that core.autocrlf=true locally. Thanks a lot, I'll be hapy to close this one as completed. Should I also set core.autocrlf=false?