Search code examples
ruby-on-railsgitubuntuwindows-subsystem-for-linuxforeman

ruby on rails "warning: shebang line ending with \r may cause problems" still occurs after tried to fixed it


I have cloned one of the repository that apply chatwoot github https://github.com/chatwoot/chatwoot, then I encountered with this warning when execute "rails s" on windows wsl (ubuntu):

/home/user/.rbenv/versions/3.0.2/bin/ruby: warning: shebang line ending with \r may cause problems

So, I found that changes git config (follow the first solution from this post) will automatically handle this problem, but after I tried with that, it's still display the same as above. https://stackoverflow.com/a/54288670/18770801

The command I tried:

git config --global core.autocrlf true

The server doesn't throw any error (just display warning) but I'm not sure if there is a way to get rid of that message?

==============================================================

Finally, I ran into the problem when I follow the project setup guide foreman start -f Procfile.dev

https://www.chatwoot.com/docs/contributing-guide/project-setup

17:13:40 backend.1  | started with pid 8482
17:13:40 frontend.1 | started with pid 8483
17:13:40 worker.1   | started with pid 8484
17:13:41 backend.1  | /usr/bin/env: ‘ruby\r’: No such file or directory
17:13:41 backend.1  | exited with code 127
17:13:41 system     | sending SIGTERM to all processes
17:13:41 frontend.1 | terminated by SIGTERM
17:13:41 worker.1   | terminated by SIGTERM

I guess that it probably comes from the same issue but I don't know how to solve that. If anyone can figure it out, please help.


Solution

  • Answer my own question:

    I've tried to solve this with trial and error several times since I cannot find any answer can solve my problem at all.

    In my case, I cloned the repository on Windows system (every files are on my device are located in 'C' drive). That's cause End-of-line format problem when running on wsl (ubuntu). The problem occurs when I tried to run script foreman start -f Procfile.dev for booting up my server. Then it throws an error that it cannot find ‘ruby\r’.

    This problem comes from the instruction line in Procfile.dev which uses bin/rails and bin/webpack-dev-server files.

    To solve this, open project with vs code. Under bin/rails and bin/webpack-dev-server files, click on CRLF format in the bottom right of your screen and change it to LF format. This will convert "CRLF" Windows' end-of-line format ("\r\n") into "LF" Linux's format ("\n"). Save both files and restart the server by execute foreman start -f Procfile.dev again, and the problem will be solved.