This project is archived and is in readonly mode.

#4153 ✓stale
Thomas Walkama

db:create cannot open database for sqlite3 on Windows with Cygwin

Reported by Thomas Walkama | March 11th, 2010 @ 02:25 PM

Took me a while to hunt this one down but after installing Rails 3 I was getting a big dump when I attempted to do a "rake db:create" using sqlite3.

$ rake db:create (in /c/src/me/test) could not open database: unable to open database file
/usr/local/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5/lib/sqlite3/errors.rb:62: in check'<br/> /usr/local/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb:7 7:ininitialize'
... Couldn't create database for {"adapter"=>"sqlite3", "database"=>"db/development.
sqlite3", "pool"=>5, "timeout"=>5000}
db/development.sqlite3 already exists

Seems this is a pretty common error and most people chalk it up to permissions or something like that. Turns out under Windows/Cygwin this has nothing to do with permissions but rather the fact the current directory is reported as /c/src/test instead of "c:\src\test". This is true whether you run rake from the Cygwin bash shell or if you start a cmd.exe ...

By editing my config/database.yml file and specifying fully qualified (DOS-style) paths, I'm able to get rake to create the databases (and migrate now works, etc.).

Editing /usr/local/lib/ruby/gems/1.9.1/gems/sqlite3-ruby-1.2.5/lib/sqlite3/database.rb I dropped in a "puts file_name" and it looks like it's getting the Cygwin-style path instead of the DOS-style one...

$ rake db:create (in /c/src/me/test) /c/src/me/test could not open database: unable to open database file

And further it appears FileUtils::pwd() returns the same (I haven't dug in but I'm guessing this may be the root cause).

I'm not sure if this is a bug or feature, but it might be worth annotating the appropriate documentation for users utilizing Cygwin under Windows (those of us unfortunate enough not to be using our Macs or Linux boxes at the moment).

Comments and changes to this ticket

  • Ryan Bigg

    Ryan Bigg October 11th, 2010 @ 10:56 AM

    • Tag cleared.
    • Importance changed from “” to “Low”

    Automatic cleanup of spam.

  • Ryan Bigg

    Ryan Bigg October 19th, 2010 @ 08:26 AM

    Automatic cleanup of spam.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:48 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:48 PM

    • State changed from “open” to “stale”
  • bingbing

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages