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

Add Section About Line Endings to Linux Troubleshooting Guide #439

Closed
cmhhelgeson opened this issue Feb 11, 2024 · 1 comment
Closed

Add Section About Line Endings to Linux Troubleshooting Guide #439

cmhhelgeson opened this issue Feb 11, 2024 · 1 comment

Comments

@cmhhelgeson
Copy link

cmhhelgeson commented Feb 11, 2024

In troubleshooting section (edit to make less verbose if you please)

My Linux console cannot find or will not execute my shell scripts:

Within Unix and Linux systems such as Ubuntu, shell scripts must have LF (Line Feed) line endings in order to properly execute with the terminal/console. However, if you are using Windows, depending on your development environment and Git settings, these line endings may have been converted to CRLF (Carriage Return Line Feed) line endings, which prevent your shell files from being properly executed within a Linux context.

Within the immediate, there are two options to remedy this issue:

  1. Manually change the line endings of the file from CRLF to LF within your IDE of choice.
  2. Install and run the dos2unix package on your troublesome file by running these commands:
sudo apt install dos2unix
dos2unix <name_of_shell_file>

To convert each file within your directory to LF line endings, simply run this command instead:

find . -type f -exec dos2unix {} +

To prevent Git from changing file line endings during the cloning or forking process, simply type in the command below. This command will prevent Git from performing any contextual conversions on the line endings of cloned files, thus preserving the files' original line endings.

git config --global core.autocrlf false

Alternatively, you could run the following command instead, which simply converts any CRLF files to LF line ending files, while maintaining files which already have LF line endings.

git config --global core.autocrlf input
@zachgoll
Copy link
Collaborator

This is a great explanation of the problem at hand but would like to keep the guides as concise as possible. So I'll go ahead and link back to this issue for those who need some additional context!

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

2 participants