ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects
http://throwtheswitch.org
Other
582 stars 244 forks source link

bad interpreter on "ceedling new --local" #478

Open kneeev opened 4 years ago

kneeev commented 4 years ago

Description

When trying to run ./ceedling after creating a new project with

ceedling new --local ProjectName

I get the output:

-bash: ./ceedling: /bin/bash^M: bad interpreter: No such file or directory

Machine

OS: Ubuntu 18.04.4 LTS (x64)

Linux ubuntu 5.3.0-42-generic #34~18.04.1-Ubuntu SMP Fri Feb 28 13:42:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Suggested Solution

Remove '\r' in line endings for Linux based operating systems.

mvandervoord commented 4 years ago

Do you know where you are you seeing a \r?

Ceedling is primarily developed on a mac, which is a *nix OS. It's also based on Ruby, which is already line-ending agnostic. While it's definitely possible that this is the problem you're seeing, I'm not running into the same.

The most likely scenario seems like it would be the ceedling file that gets copied into the project, or maybe the yaml file that's created. Do you have a way to show line endings to check either of those to see if they have this problem?

I'm trying to reproduce it from my side, but so far, no luck. Any exploration to help hunt it down on your end would definitely be appreciated!

Also, I assume if you do gem list it shows ceedling is 0.29.1?

kneeev commented 4 years ago

both the ceedling bash script and the project.yml files use \r\n Ceedling's versions is 0.29.1

mvandervoord commented 4 years ago

That's interesting. Did you install it through gem install? clone it from github? download it as a zip?

On Sun, Mar 22, 2020 at 9:41 AM Niv Govrin notifications@github.com wrote:

both the ceedling bash script and the project.yml files use \r\n Ceedling's versions is 0.29.1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/478#issuecomment-602202616, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEA73ESBMVBSGJA3MZH6LRIYIPLANCNFSM4LRI53ZA .

kneeev commented 4 years ago

gem install

gem version: 2.7.6 ruby version: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]

mvandervoord commented 4 years ago

Does fixing the line endings on the bash script fix the problem for you? The rest would be going through the Ruby interpreter, which should be automatically fixing line endings (unless there is a place I've missed?)

In any case, I'll make sure the correct line endings exist for the bash script.

On Sun, Mar 22, 2020 at 12:16 PM Niv Govrin notifications@github.com wrote:

gem install

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/478#issuecomment-602233449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEA75DUPVO62G36INLGFLRIY2U5ANCNFSM4LRI53ZA .

kneeev commented 4 years ago

fixing the line endings in the bash script fixes the problem, but displays this warning when running the script:

ruby: warning: shebang line ending with \r may cause problems

to make this disappear, I ran dos2unix on all the files in the directory.

mvandervoord commented 4 years ago

That's really interesting. I might have made the last release gem on Windows (usually I push it from my mac or ubuntu machines)... but I test it on all of those machines as well and haven't run into the same warnings.

It's particularly strange that ruby is warning you about the carriage returns. Usually ruby tries to be as platform agnostic as possible. I wonder if their philosophy on how best to accomplish that is changing.

Thanks for helping to work this out. I'll see what I can do to get it all happier!

Mark

On Mon, Mar 23, 2020 at 10:59 AM Niv Govrin notifications@github.com wrote:

fixing the line endings in the bash script fixes the problem, but returns this warning when running the script:

ruby: warning: shebang line ending with \r may cause problems

to make this disappear, I ran dos2unix on all the files in the directory.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/478#issuecomment-602652883, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEA7Y5AOMCW3R66ZV7EFLRI52LVANCNFSM4LRI53ZA .

kneeev commented 4 years ago

I didn't notice any problem with the ruby scripts. It prints the warning, but continues to run normally. Maybe it prints that in case some external program relies on it being with the correct line-endings.

austinglaser commented 4 years ago

Usually ruby tries to be as platform agnostic as possible.

The shebang is usually interpreted by an external program (your shell, for instance). Doesn't matter how platform-agnostic ruby is if the interpreter never gets called -- which is the likely reason for the warning.

mvandervoord commented 4 years ago

That's good to know. I prefer to be in a situation where we aren't producing warnings at all, though. That might be impossible given the number of targets we support... but it's always the goal. :)

On Mon, Mar 23, 2020 at 11:11 AM Niv Govrin notifications@github.com wrote:

I didn't notice any problem with the ruby scripts. It prints the warning, but continues to run normally. Maybe it prints that in case some external program relies on it being with the correct line-endings.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/478#issuecomment-602663394, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEA7ZW6YPY7Q5YVMHTLNDRI5327ANCNFSM4LRI53ZA .

austinglaser commented 4 years ago

Seems to be the best goal! That way, when you do get warnings they get noticed and acted on.

mvandervoord commented 4 years ago

So for this problem, I'm taking the following actions. What do you think about this plan?

(1) I'm updating the .gitattributes file to NOT touch the line endings of the windows and linux shell command files. (2) I'm manually updating those line endings to be correct. (3) only going to do gem releases from a *nix-compatible machine in the future... I feel confident that Windows Ruby has been designed to consume \n without complaint, or gems would be broken all over the place.

I think this should cover most of the issues we run into? Thoughts?

Mark

On Mon, Mar 23, 2020 at 11:26 AM austinglaser notifications@github.com wrote:

Seems to be the best goal! That way, when you do get warnings they get noticed and acted on.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ThrowTheSwitch/Ceedling/issues/478#issuecomment-602673129, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEA7YUSVUIWGV6F5VVCN3RI55TJANCNFSM4LRI53ZA .

kneeev commented 4 years ago

Sounds like that should solve the issue.