I'm currently developing for a Ruby on Rails application. I am on a windows machine, using ubuntu through WSL. We have rubocop setup to track formatting on git pushes, and I always run into the same issue. When adding this comment to the top of any file, I receive the error Layout/EndOfLine: Carriage return character detected
. The issue seems to be talked about here as well Layout/EndOfLine: Carriage return character detected. module TieConnector
# frozen_string_literal: true
The solution here seems to be to disable the warning, or manually convert the files before pushing.
Does anyone know if there is another solution here? I don't believe I can edit the rubocop settings as it is not my project. The converting method does work, but gets a bit tedious to do every time I make a new pull request.
Would there be a way to run the dox2unix convert when running git push
while targeting the files staged for commit? Or a way to force my machine to use the unix encoding by default?
Any help is appreciated, thank you
CodePudding user response:
It's a common issue on windows. If you are using vscode you can convert all your files to LF with this shortcut: ctrl shift P => 'change all end of line sequence' => Enter => Enter => Enter => 'LF' => Enter Then you can commit and push your code. If it still don't work you might see your git configuration, autocrlf in particular. See this response: stackoverflow.com/a/20653073/7542830
To solve it on a repository level:
git config --local core.autocrlf input
(on you project root)