I also had the same problem when I was trying to run bin/rails db:create
. It took me hours trying to figure out the problem and yet it was an easy fix. I am using Visual Studio Code as my editor.
My solution
To solve this, I navigated to the ruby
file located in the bin
folder(bin/rails
). At the bottom of the Visual Studio Code editor(status bar), you should be able to see a button CRLF
(control character). Click on it and change it to LF
.
Reason for the error message
This is because Windows by default uses the CRLF
control character and now that you are using a Windows subsystem for Linux, the control character should be LF
I hope this helps anyone out there.