fdopen / opam-repository-mingw

windows package repository for OPAM (mingw and msvc)
https://fdopen.github.io/opam-repository-mingw/
Creative Commons Zero v1.0 Universal
96 stars 33 forks source link

winconfigure error with carriage returns #40

Closed bcc32 closed 7 years ago

bcc32 commented 7 years ago

I tried opam install sexplib using the opam-repository-mingw installer and got the following error message:

$ opam install sexplib
The following actions will be performed:
  ∗  install sexplib v0.9.2

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[sexplib: sh winconfigure] Command started
[ERROR] The compilation of sexplib failed at "sh winconfigure".

#=== ERROR while compiling sexplib.v0.9.2 =====================================#
# opam-version         1.3.0~dev (2c2399d98ad0ebcb43a4bc856f3636030bb376db)
# os                   win32
# command              sh winconfigure
# path                 ~/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2
# exit-code            2
# env-file             ~/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2\sexplib-376-5f1023.env
# stdout-file          ~/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2\sexplib-376-5f1023.out
# stderr-file          ~/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2\sexplib-376-5f1023.err
### stderr ###
# winconfigure: line 2: $'\r': command not found
# winconfigure: line 4: $'\r': command not found
# winconfigure: line 5: syntax error near unexpected token `$'in\r''
' winconfigure: line 5: `case "$OS_SYSTEM" in

=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
  λ  build sexplib v0.9.2
No changes have been performed

The error messages suggest to me that the problem might be similar to the one discussed here and at ocaml/merlin#682.

fdopen commented 7 years ago

No, the \r\n thing has always been managed by this repo. The script winconfigure itself apparently contains carriage returns, while the upstream version doesn't contain one. There is probably something wrong with your git configuration or there is a non-cygwin git before cygwin's git in your $PATH.

What`s the output of:

which git
git --version
file ~/.opam/packages/sexplib/sexplib.v0.9.2/files/winconfigure
bcc32 commented 7 years ago

Hmm, I see. The sexplib package is missing from the packages directory since it didn't get installed.

$ which git
/usr/bin/git

$ git --version
git version 2.14.1

$ git config core.autocrlf
true

$ file ~/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2/winconfigure
(snip)/.opam/4.05.0+mingw64c/build/sexplib.v0.9.2/winconfigure: POSIX shell script, ASCII text executable, with CRLF line terminators

I tried setting core.autocrlf to input and nuked the build/sexplib.v0.9.2 directory, but I got the same error.

fdopen commented 7 years ago

Ok, it was probably because git config core.autocrlf was true. I've now enforced Unix LF via .gitattributes (a7245d89f4e01715b5b79c6d2c60bbde7de4bec1). This way it should work regardless of your default settings for core.autocrlf.

You must however convert your existing repo manually to the new line endings:

opam update # fetch the change
cd ~/.opam/repo/mingw
git rm -rf --cached .
git reset --hard HEAD
cd ~/
opam install sexplib

or just start again with a fresh opam root:

mv ~/.opam ~/.opam.old
opam init --comp 4.05.0+mingw64c --switch 4.05.0+mingw64c
bcc32 commented 7 years ago

Looks like it's working now. Thanks for the help!