1

I am trying to build mono on windows, but the .sh files give errors about the carriage returns :

$ ./autogen.sh --host=i686-pc-mingw32 --profile=/usr/opt
./autogen.sh: line 4: $'\r': command not found
./autogen.sh: line 6: $'\r': command not found
./autogen.sh: line 9: $'\r': command not found

The .gitattributes file has this line({cr:

*.sh    crlf

I can edit and remove the cr, but then when I try to do a reset so that it will blow away the local file and reget the file from origin, the gitattributes are also blown away:

git fetch origin master
git reset --hard FETCH_HEAD

Looking at the mono repository, they have the .gitattributes like this, but none of the build instructions addresses this issue.

What is the proper way to deal with line endings when building mono on windows? Surely I'm not supposed to manually run dos2unix after everytime I pull?

AaronLS
  • 37,329
  • 20
  • 143
  • 202

1 Answers1

2

Make sure that you have

git config --global core.autocrlf false

That will avoid global conversion done (in addition of the .gitattributes directive)

I can edit and remove the cr

Yes, but then you need to add and commit first, before doing the:

git rm --cached -r .
git reset --hard

Otherwise, the .gitattributes would be restored to its previous state.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Feels odd to have to commit a change like that, but I'll take your word. Why would they have .sh files configured in that way? It seems like the CR would break the *.sh on both linux and windows? – AaronLS Feb 22 '14 at 07:39
  • I commited the .gitattributes and deleted the .sh file and did reset, but still got pulled with CRLF. I then did the --global change and reset again, and that time it only had LF. I would think a .gitattribute would be a more specialized setting thus override the global. Would suck if one project needed it set one way and another needed it another way :/ – AaronLS Feb 22 '14 at 07:55
  • @AaronLS Agreed. I never liked that setting `core.autocrlf` (http://stackoverflow.com/a/20168775/6309) – VonC Feb 22 '14 at 08:01