Linux “: command not found” Error – Windows Line Break

Today, I am working on a project, that uses Puppet template to create a stackdriver config file: /etc/sysconfig/stackdriver

For some reason, this Puppet template (.erb) is ‘dos’ file format (from my colleague), which is Windows format. The line break is CR + LF. Usually this is OK, because the config file mostly just for Linux service to read. However, in stackdriver service startup script, there is a line ‘ . /etc/sysconfig/stackdriver ‘. Stackdrive service uses this config file to initial certain variables. In this case, if you have Windows line breaks in the config file, you will see this error:

: command not found
: command not found

I then use sublime text to recreate this file in unix file format, problem goes away. Hope this helps someone.

These sublime text personal preference setting are recommended, unless you are a Windows platform developer:

{
"default_line_ending": "unix",
"translate_tabs_to_spaces": true
}

Update: It turns out it is because I copied the files from my Windows PC over to Linux server. What I should do is to git clone the files on the Linux server. This way Git will help deal with the line ending issue.

Leave a Reply

Your email address will not be published. Required fields are marked *