lollms-webui icon indicating copy to clipboard operation
lollms-webui copied to clipboard

linux_install.sh has CR line endings, causing it to error

Open cha0sbuster opened this issue 1 year ago • 11 comments

Expected Behavior

Running linux_install.sh should cause the shebang to be parsed correctly.

Current Behavior

The shebang in linux_install.sh is not parsed correctly. (error: bad interpreter: /bin/bash^M: no such file or directory)

Steps to Reproduce

  1. Run linux_install.sh on a shell which is sensitive to line ending type, such as zsh.

Possible Solution

Save linux_install.sh with LF line endings, rather than CR LF (the DOS/Windows default) or CR (the MacOS default). This is achievable in all major text editors, alternatively dos2unix can be used.

Context

If encountered, this issue can be worked around by users without leaving the terminal by using the dos2unix utility, installable from the repos of all major distributions (and Brew on MacOS, if encountered there.)

Screenshots

Not applicable.

cha0sbuster avatar Aug 28 '23 04:08 cha0sbuster

Hi. Thanks for your remark. I only have windows and wrote the linux code blindly without testing. I'll try to fix this issue when I can.

ParisNeo avatar Aug 28 '23 15:08 ParisNeo

I had to run the following command to fix this issue.

sed -i -e 's/\r$//' ./linux_install.sh

mahdiyari avatar Feb 15 '24 10:02 mahdiyari

You are right. This is the problem when someone codes blindfolded. I don't have a linux machine to test my codes and windows keeps changing the end of line. That's horrible.

I can accept pull requests, if you want to do that for me.

ParisNeo avatar Feb 15 '24 11:02 ParisNeo

You should be able to set the file's line endings in most text editors that are worth using. Git should also be converting to LF automatically. So I'm not entirely certain what the problem is, but I have a feeling it's in your dev environment. You can also use WSL to test Linux implementations on Windows.

I had to run the following command to fix this issue.

sed -i -e 's/\r$//' ./linux_install.sh

dos2unix is also a standard feature of most distros AFAIK, probably easier than fiddling with sed.

cha0sbuster avatar Feb 15 '24 20:02 cha0sbuster

You are right. This is the problem when someone codes blindfolded. I don't have a linux machine to test my codes and windows keeps changing the end of line. That's horrible.

I can accept pull requests, if you want to do that for me.

The problem is that you didn't select the correct line endings when you installed git. You should reinstall it and select the default option.

lee-b avatar Feb 24 '24 15:02 lee-b

You should be able to set the file's line endings in most text editors that are worth using. Git should also be converting to LF automatically. So I'm not entirely certain what the problem is, but I have a feeling it's in your dev environment. You can also use WSL to test Linux implementations on Windows.

I had to run the following command to fix this issue.

sed -i -e 's/\r$//' ./linux_install.sh

dos2unix is also a standard feature of most distros AFAIK, probably easier than fiddling with sed.

Beleive me I did. It is my windows git that is doing this over and over again.

ParisNeo avatar Feb 25 '24 21:02 ParisNeo

Under no circumstances should Git be converting LF-saved files to CRLF; this is simply not a thing Git does. It should only go the other way around.

Git might be preserving the old config, or the config might be saved somewhere in the repository.

Try this.

Try it from inside the repository folder as well, with and without --global. If the culprit is an override having been set wrong when the repo was created, that might do it.

You can check the line endings by cloning the repo from GitHub on your own machine (from a .zip file so core.autocrlf doesn't convert them back) and opening it in Notepad, since modern Notepad indicates line endings on the bottom.

Push comes to shove, a nuclear option would be to recreate the repo, ensuring core.autocrlf is set to true globally, and copy your code over by hand, perhaps running dos2unix on everything from a WSL2 container for good measure.

Git is also a bit of a beast to me, so I can't say for sure that this'll help, but it's something.

cha0sbuster avatar Feb 25 '24 22:02 cha0sbuster

I have changed all crlf to lf in linux scripts and then pushed them.

ParisNeo avatar Mar 01 '24 22:03 ParisNeo

Awesome, sorry for the delay in my response but I'll give it a shot soon.

It also appears I owe you an apology. Git does convert to CRLF when checking out text files when core.autocrlf is set to true. But it should also be converting them to LF again when you commit. Are you committing from Git, or are you uploading the files right to GitHub? (No shame intended, I do that too even though I probably shouldn't...)

cha0sbuster avatar Mar 31 '24 04:03 cha0sbuster

hi. Oh not again. I'm sorry for that, just use dos2unix to convert it. i always forget that when I add a new release lol. I'll fix this.

ParisNeo avatar Apr 01 '24 11:04 ParisNeo

Oh, no, I haven't tested it yet. I was just thanking you for the update! It still feels like this should be worked around in your development environment, but again, I'm not you. You might want to bring this up with the Git for Windows folks, see if they can help you figure out what's gone wrong.

cha0sbuster avatar Apr 02 '24 01:04 cha0sbuster