Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ocaml-env seems to change some unrelated file's newline behavior? #92

Open
chenglou opened this issue Apr 29, 2021 · 1 comment
Open

Comments

@chenglou
Copy link

Hello! I'm running your stack on GitHub Action Windows CI, with the current default git settings (checked out files as CRLF). However, it seems that ocaml-env exec -- trivialScript changes some things. The files are still in CRLF but in my setup, git diff is showing a diff, possibly a stale git diff cache (I hardly believe this is actually the case but I've checked all the file's line ending at every step of my commands).

Tldr:

  • CI windows git checkout with CRLF
  • file.txt still in CRLF
  • git diff empty
  • run trivialScript
  • file.txt still in CRLF of course
  • git diff still empty
  • run ocaml-env exec --trivialScript
  • file.txt still in CRLF
  • git diff now shows that there are diffs, but the diff view shows that there isn't any (including, no newline changes. Unless I'm using git diff's options wrong):
    -foo
    +foo
    

I'm unfamiliar with where I can find the source to ocaml-env; do you know what could have happened here?

@chenglou
Copy link
Author

cc @smorimoto who'll probably want to know about this =)

chenglou added a commit to rescript-lang/rescript-vscode that referenced this issue Apr 29, 2021
GitHub Action checks out code on windows on CRLF. This PR tried many methods of just using CRLF or converting to LF.

Tips:
- `print_endline` and multiline strings on windows ocaml fork use CRLF. `open_in_bin` + `really_input_string` too (!)
- `dos2unix` hangs when used inside `test.sh` but doesn't hang inside `ci.yml`.
- `cat` and `pipe` don't change line ending.
- use `cat -A` to check for line endings visibly. Life saving debugger.
- `sed "s/\r\n/\n/g"` apparently doesn't work on CI windows...
- `git checkout` + `ocaml-env` bug (?) fdopen/opam-repository-mingw#92

Whichever method of directly using CRLF doesn't work because of the last issue; it's likely that I'm being dumb...
So right now we set git to checkout using LF, let our native code output to CRLF, then instead of `dos2unix` or `sed`, use a perl one-liner in `test.sh` to convert those back into LF for comparison.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant