Skip to content

Docker image does not build #1250

Closed
Closed

Description

@edqallen

Clean clone of the git repo several minutes ago. Attempted to build docker container with simple command docker build -t graphhopper:master . which resulted in a failure at step 7:

Step 7/11 : RUN ./graphhopper.sh buildweb
 ---> Running in dda109ba2819
/bin/sh: 1: ./graphhopper.sh: not found
The command '/bin/sh -c ./graphhopper.sh buildweb' returned a non-zero code: 127

The issue appears to be that graphhopper.sh is in DOS/CRLF format, which means the shell specified in the shebang cannot be found, since it is looking for /bin/bash^M instead of just /bin/bash. Converting the file to unix newlines results in a successful build.

Activity

  1. edqallen commented on Dec 27, 2017

    @edqallen
    Author

    Of course, this was my git setting to blame doing conversion on checkout, not the fault of the project. kicks self.

  2. edqallen commented on Dec 27, 2017

    @edqallen
    Author

    I have spoken too soon and am reopening this.

    My global git setting is correct, in that I have autocrlf disabled, however the .gitattributes file in this project is overriding that and setting it to auto via text=auto. Windows has correctly handled unix/LF files for 10 or 15 years now; forcing git to convert them to CRLF's on windows is bad behavior, and the source of the build error in the original message.

    I believe the whole .gitattributes file should just be removed from the project.

  3. devemux86 commented on Dec 27, 2017

    @devemux86
    Contributor

    Can see also related GitHub documentation.

  4. edqallen commented on Dec 27, 2017

    @edqallen
    Author

    @devemux86 that doesn't help. The project contains a .gitattributes file which overrides the core.autocrlf setting, no matter what I set it to. The setting in the .gitattributes file is wrong -- it is converting line endings on windows to CRLF, which is incorrect, they should be LF just like they are on OSX & Linux.

    This can be changed by changing the * text=auto line in the /.gitattributes file to * text eol=lf.

  5. devemux86 commented on Dec 27, 2017

    @devemux86
    Contributor

    If a specific file type needs to remain consistent across all platforms, can declare only that in .gitattributes, e.g.:

    *.sh text eol=lf
    

    BTW after such changes, it's usually recommended to refresh the local repository in order to receive the new files.

  6. edqallen commented on Dec 27, 2017

    @edqallen
    Author

    @devemux86 there is literally not a specific type of file that does need converted to CRLF. I'm struggling to understand why this override was put in the .gitattributes file in the first place -- all it's doing is overriding the correct behavior I already had in my global .gitconfig file, replacing it with incorrect behavior.

  7. edqallen commented on Dec 28, 2017

    @edqallen
    Author

    @karussell I don't know what that link is supposed to do for me... The problem I'm having is caused by the .gitattributes file in the root of the project. The instructions in that file are causing the bash shell script to be converted from LF terminated lines to CRLF terminated lines by git when pulled/cloned.

    CRLF terminated files do not work as a shell scripts.

    The fix is to stop converting the .sh files to CRLF on windows. This is easy to accomplish by simply deleting that .gitattributes file from the project -- it serves no purpose except to make development & use on windows more difficult, which is ironic, since the purpose of those settings is to make it easier.

  8. devemux86 commented on Dec 28, 2017

    @devemux86
    Contributor

    Unix, Linux and OS X use LF and Windows uses CRLF to denote the end of a line.

    "Optionally, you can configure the way Git manages line endings on a per-repository basis by configuring a special .gitattributes file. This file is committed into the repository and overrides an individual's core.autocrlf setting, ensuring consistent behavior for all users, regardless of their Git settings. The advantage of a .gitattributes file is that your line configurations are associated with your repository. You don't need to worry about whether or not collaborators have the same line ending settings that you do."

    Collaborated work can introduce whitespace changes because editors could silently introduce them, and if any files ever touch a Windows system, their line endings might be replaced(?).

    Though @karussell jsprit doesn't have such config?
    The .sh file seems candidate for consistent line ending everywhere.

  9. edqallen commented on Dec 28, 2017

    @edqallen
    Author

    @davemux86 I'm painfully aware of these settings now, my point is this: That file is serving one purpose -- to force files to be converted to CRLF format on windows. There is no reason to do that conversion. Windows developers can edit LF terminated files just fine. This file is not helping anyone, it's just causing problems.

    Unix, Linux and OS X use LF and Windows uses CRLF to denote the end of a line.

    This is, simply, incorrect. "Windows" does not use CRLF, it doesn't care. Some editors on Windows default to CRLF for new files and others default to LF, but all of them (except notepad) work perfectly fine with either type of file.

    Collaborated work can introduce whitespace changes because editors could silently introduce them

    Silently? No, not really. Every modern editor on Windows asks you if you want to change the file format, it doesn't just blindly do it, and they only ask if they detect mixed line endings in the file (the result of copy/pasting from a file with a different format). Otherwise, they leave the files in the format they were in when opened. Open a CRLF file, it's saved as a CRLF file. Open an LF file, it's saved as an LF file.

  10. legraina commented on Dec 28, 2017

    @legraina
    Contributor

    Turning off the autocrlf should fix the issue, as the docker image is running under linux.

    I've also tried to change RUN ./graphhopper.sh buildweb to RUN /bin/bash -c ./graphhopper.sh buildweb and ENTRYPOINT [ "./graphhopper.sh", "web" ] to ENTRYPOINT [ "/bin/bash", "-c", "./graphhopper.sh", "web" ], and it worked also fine (but I'm on mac or linux).

    @karussell was giving you this link (https://hub.docker.com/r/graphhopper/graphhopper/tags/), so you can use the latest docker image already compiled (and avoid this problem). Just run docker run -p 11111:11111 graphhopper/graphhopper and you will run the latest image. You can also add the map that you would like to load with docker run graphhopper/graphhopper /data/europe_monaco.pbf

  11. edqallen commented on Dec 28, 2017

    @edqallen
    Author

    @legrania no, changing autocrlf does not solve the issue. My autocrlf was already off -- the .gitattributes file overrules that setting from .gitconfig which is why I opened this ticket in the first place.

    and it worked also fine (but I'm on mac or linux).

    None of those work on Windows. The contents of the .gitattributes file are overriding my (correct) .gitconfig autocrlf setting. If you're not using Windows yourself, you can't see first hand the problems this file is causing.

    Once more, to explain as briefly as I can what is happening in the hopes that you'll understand:

    1. Execute git clone. The .gitattributes file within the repo instructs git to change all text files (css, html, java, sh, etc) to be CRLF line terminated regardless of the global autocrlf setting.

    2. Execute docker build. The build fails because the .sh file that is run has been modified by git clone to have CRLF line terminators, which are invalid in a linux shell script.

    This only happens on windows (so you testing on linux and OSX don't show it) because git is only converting to CRLF when it determines that it is on windows -- and it's only doing this conversion because someone told it to with this .gitattributes file!

    Is there anyone working on this project that is developing on windows? If I'm the only one, can't you just take my word for it and remove this file? I promise you that, as a windows developer, I do not need git converting files to have CRLF line terminators -- I can work with LF terminated files perfectly well, and have been able to do so for many many years.

  12. karussell commented on Dec 28, 2017

    @karussell
    Member

    Sure, we can remove this file if this causes troubles, but without it there were problems too, see #449 and #190 (comment) ... maybe @ratrun can share experience?

  13. edqallen commented on Dec 28, 2017

    @edqallen
    Author

    @domi-nique never responded to say if the issue was fixed for them with those changes, but they couldn't have been -- or else the project would be working for me too. I think the changes were made and committed but never tested by anyone actually using Windows.

    Changing the line that reads * text=auto to * text=lf would have the desired effect and cover people using windows who have not correctly configured git, but personally I'd rather just see the file deleted and even added to the .gitignore file. This way if someone on Windows does have a problem (say because their global autocrlf is set to true) they can either change their global config, or they can make their own .gitattributes file just for this project, which has * text=lf in it and a notation that a .sh file is text.

    All that stuff with the other file types like java, html, css, etc is just making things worse. At a minimum if you don't want to remove the file, the contents should be replaced with this:

    # Set default behaviour, in case users don't have core.autocrlf set.
    * text=lf
    
    # Explicitly declare text files we want to always be normalized and converted 
    # to unix line endings on checkout.
    *.sh text
    

    There is no reason to intentionally convert all those other files to CRLF on windows.

  14. karussell commented on Apr 20, 2018

    @karussell
    Member

    Ok, it looks like this does indeed not work. So will try your suggestion 😃

  15. added a commit that references this issue on Apr 20, 2018
  16. karussell commented on Sep 10, 2018

    @karussell
    Member

    Closing for now. Please reopen if you think there is a better fix should do for windows.

  17. nathanwaters commented on Dec 6, 2018

    @nathanwaters

    For anyone else experiencing this stupid issue, simply download the repo zip rather than cloning. Worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions