question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spotless does not respect line endings on Windows 10

See original GitHub issue

We have lineEndings = 'unix'; specified in our Spotless config, but it appears to not be respected in Windows 10 or Windows Server 2016.

Here are the instructions to reproduce:

I ran ./gradlew spotlessApply on the Windows 10 machine using git bash this is what has happened. NOTE: I started the below steps on a fresh git clone of the open side. [Steps:

  1. git clone https://git-wip-us.apache.org/repos/asf/incubator-geode.git open
  2. cd open
  3. git checkout -b develop origin/develop]

Step 1. ./gradlew clean build -Dskip.tests=true

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:geode-core:spotlessJavaCheck’. Format violations were found. Run ‘gradlew spotlessApply’ to fix them.

geode-core\src\main\java\org\apache\geode\internal\statistics\StatArchiveReader.java

geode-core\src\test\java\org\apache\geode\cache\query\dunit\PdxLocalQueryVersionedClassDUnitTest.java

geode-core\src\test\java\org\apache\geode\internal\cache\execute\ClientServerFunctionExecutionDUnitTest.java

geode-core\src\test\java\org\apache\geode\internal\cache\functions\TestFunction.java

geode-core\src\test\java\org\apache\geode\internal\statistics\StatArchiveWithMissingResourceTypeRegressionTest.java

Step 2: ./gradlew spotlessApply

BUILD SUCCESSFUL

Total time: 12.728 secs

Step 3: git status

modified: geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java modified: geode-core/src/test/java/org/apache/geode/cache/query/dunit/PdxLocalQueryVersionedClassDUnitTest.java modified: geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java modified: geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java modified: geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java

Step 4 : git add . warning: LF will be replaced by CRLF in geode-core/src/main/java/org/apache/geode/internal/statistics/StatArchiveReader.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/cache/query/dunit/PdxLocalQueryVersionedClassDUnitTest.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/cache/execute/ClientServerFunctionExecutionDUnitTest.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/cache/functions/TestFunction.java. The file will have its original line endings in your working directory. warning: LF will be replaced by CRLF in geode-core/src/test/java/org/apache/geode/internal/statistics/StatArchiveWithMissingResourceTypeRegressionTest.java. The file will have its original line endings in your working directory.

Step 5: git status On branch develop Your branch is up-to-date with ‘origin/develop’. nothing to commit, working tree clean

Step 6: ./gradlew clean build -Dskip.tests=true BUILD SUCCESSFUL

Total time: 5 mins 28.64 secs

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jaredjstewartcommented, Nov 4, 2016

I thought Git only mucked with line endings when you add files, I didn’t know it actually did that on checkout. Thank you so much for your explanation.

0reactions
nedtwiggcommented, Nov 4, 2016

If there’s any truth in the world, it’s this: git is always mucking with your line endings 😉

Everything I said above can be changed based on a variety of more obscure git settings files spread across your machine-global config, your home directory, and your repo. But .gitattributes blasts all that and defines the truth unambiguously, which is why the README says to just make one and ignores the rest.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spotless complains about line endings on Windows with core ...
My Git is configured to core.autocrlf=false , so the line endings in my working copy are \n. Creating a .gitattributes file with the...
Read more >
No option to specify end of line (EOL) to be LF rather than CRLF
Of course, Windows prefers CRLF line endings and Unix prefers LF line endings. Almost everything has an option to specify which line endings...
Read more >
Git checking out a specific file only with LF line endings on ...
To fix this I converted the line endings to LF on my Windows box and committed the file. This now works great on...
Read more >
Introducing extended line endings support in Notepad
New files created within Notepad will use Windows line ending (CRLF) by default, but it will now be possible to view, edit, and...
Read more >
Spotless converting newlines to CRLF - IDE & Build
Spotless always converts the newlines to CRLF in my environment, very annoying -.- Does somebody know how to solve this?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found