Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

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

#4153

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).

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

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:56 AM

  2. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:26 AM

  3. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:48 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:48 PM

  5. bingbing