You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
@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.
@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.
@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.
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.
@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.
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).
@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:
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.
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.
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?
@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.
Activity
edqallen commentedon Dec 27, 2017
Of course, this was my git setting to blame doing conversion on checkout, not the fault of the project. kicks self.
edqallen commentedon Dec 27, 2017
I have spoken too soon and am reopening this.
My global git setting is correct, in that I have
autocrlfdisabled, however the.gitattributesfile in this project is overriding that and setting it to auto viatext=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.
devemux86 commentedon Dec 27, 2017
Can see also related GitHub documentation.
edqallen commentedon Dec 27, 2017
@devemux86 that doesn't help. The project contains a
.gitattributesfile which overrides thecore.autocrlfsetting, no matter what I set it to. The setting in the.gitattributesfile 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=autoline in the/.gitattributesfile to* text eol=lf.devemux86 commentedon Dec 27, 2017
If a specific file type needs to remain consistent across all platforms, can declare only that in .gitattributes, e.g.:
BTW after such changes, it's usually recommended to refresh the local repository in order to receive the new files.
edqallen commentedon Dec 27, 2017
@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
.gitattributesfile in the first place -- all it's doing is overriding the correct behavior I already had in my global.gitconfigfile, replacing it with incorrect behavior.karussell commentedon Dec 27, 2017
You can also try: https://hub.docker.com/r/graphhopper/graphhopper/tags/
edqallen commentedon Dec 28, 2017
@karussell I don't know what that link is supposed to do for me... The problem I'm having is caused by the
.gitattributesfile 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
.shfiles to CRLF on windows. This is easy to accomplish by simply deleting that.gitattributesfile 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.devemux86 commentedon Dec 28, 2017
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.
edqallen commentedon Dec 28, 2017
@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.
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.
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.
legraina commentedon Dec 28, 2017
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 buildwebtoRUN /bin/bash -c ./graphhopper.sh buildwebandENTRYPOINT [ "./graphhopper.sh", "web" ]toENTRYPOINT [ "/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/graphhopperand you will run the latest image. You can also add the map that you would like to load withdocker run graphhopper/graphhopper /data/europe_monaco.pbfedqallen commentedon Dec 28, 2017
@legrania no, changing autocrlf does not solve the issue. My autocrlf was already off -- the
.gitattributesfile overrules that setting from.gitconfigwhich is why I opened this ticket in the first place.None of those work on Windows. The contents of the
.gitattributesfile are overriding my (correct).gitconfigautocrlf 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:
Execute
git clone. The.gitattributesfile 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.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
.gitattributesfile!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.
karussell commentedon Dec 28, 2017
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?
edqallen commentedon Dec 28, 2017
@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=autoto* text=lfwould 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.gitignorefile. 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.gitattributesfile just for this project, which has* text=lfin it and a notation that a.shfile 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:
There is no reason to intentionally convert all those other files to CRLF on windows.
karussell commentedon Apr 20, 2018
Ok, it looks like this does indeed not work. So will try your suggestion 😃
improve lf for windows #1250
karussell commentedon Sep 10, 2018
Closing for now. Please reopen if you think there is a better fix should do for windows.
nathanwaters commentedon Dec 6, 2018
For anyone else experiencing this stupid issue, simply download the repo zip rather than cloning. Worked for me.