Help Center/ CodeArts Agent/ FAQs/ Compatibility/ How Do I Handle Windows CRLF Line Endings That Cause Execution Errors in Linux?
Updated on 2026-07-30 GMT+08:00

How Do I Handle Windows CRLF Line Endings That Cause Execution Errors in Linux?

Symptom

The generated file contains Windows CRLF line endings and cannot run on Linux.

Cause Analysis

By default, script files written on Windows use Windows CRLF line endings. When the script is run on Linux, \r is treated as a regular character, causing execution errors.

Solution

You can define agent behavior using the Rules feature provided by CodeArts Agent. You can create project and user rules in CodeArts Agent. This section uses project rules as an example. For details about how to create user rules, see Rules.

  1. Log in to CodeArts Agent by referring to Quick Start.
  2. Click in the upper right corner of CodeArts Agent IDE to open the settings page.
  3. Choose Skills and Rules and click next to Rules on the Project tab.
  4. Set parameters and click OK to create a rule.

    Figure 1 Creating a rule

  5. Simplify the file based on the rule.

    1. Check the original file's line ending format. In CodeArts Agent chat box, enter the prompt "What is the line ending format of the *** file?" and click .

      Replace *** with the actual file name. In this example, the file name is check_service_status.sh.

    2. Simplify the file. Enter the prompt "Simplify the check_service_status.sh file" and click . The agent will simplify the file based on the configured rule.
    3. Check the line ending format of the simplified file. Enter the prompt "What is the line ending format of the check_service_status.sh file?" and click .

      After simplification, the line ending format has been changed to LF, which can be executed on Linux.