# Permissions for an sqlite3 db? rake aborted

**URL:** <https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609>\
**Category:** Rails\
**Created:** [November 29, 2007, 9:38am UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609 "2007-11-29T09:38:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 29, 2007, 9:38am UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609/1 "2007-11-29T09:38:07Z")

</div>

It’s not clear to me why the rake fails. Would it be helpful to post  
the  
trace? seemed spammy. I assume it’s some sort of permissions issue,  
although a google search turned up other ideas (which seemed unlikely so  
I won’t repeat them).

Any and all thoughts please!

thufir@arrakis ~/rubyCode/straw $  
thufir@arrakis ~/rubyCode/straw $ ll db/  
total 4  
drwxr-xr-x 2 thufir users 4096 Nov 29 00:31 migrate  
-rw-rw-rw- 1 thufir users 0 Nov 29 00:31 straw.db  
thufir@arrakis ~/rubyCode/straw $  
thufir@arrakis ~/rubyCode/straw $ sqlite3 db/straw.db  
SQLite version 3.4.1  
Enter “.help” for instructions  
sqlite\> .schema  
sqlite\> .quit  
thufir@arrakis ~/rubyCode/straw $ cat config/database.yml

development:  
adapter: sqlite3  
dbfile: /home/thufir/straw/db/straw.db  
test:  
adapter: sqlite3  
dbfile: /home/thufir/straw/db/straw.db  
production:  
adapter: sqlite3  
dbfile: /home/thufir/straw/db/straw.db  
thufir@arrakis ~/rubyCode/straw $  
thufir@arrakis ~/rubyCode/straw $ cat db/migrate/001\_feeds.rb

class Feeds \< ActiveRecord::Migration  
def self.up  
create\_table :feeds do |table|  
table.column :title, :string  
table.column :location, :string  
table.column :category\_id, :integer  
end  
end  
def self.down  
drop\_table :feeds  
end  
end  
thufir@arrakis ~/rubyCode/straw $  
thufir@arrakis ~/rubyCode/straw $ rake db:migrate  
(in /home/thufir/rubyCode/straw)  
rake aborted!  
could not open database

(See full trace by running task with --trace)  
thufir@arrakis ~/rubyCode/straw $

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 29, 2007, 5:16pm UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609/2 "2007-11-29T17:16:25Z")

</div>

On Nov 29, 2007 2:36 AM, Thufir [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> thufir@arrakis ~/rubyCode/straw $ rake db:migrate  
> (in /home/thufir/rubyCode/straw)  
> rake aborted!  
> could not open database

I had this problem once a while ago. My Ruby had sqlite version 2  
support instead of version 3 or something like that. My point is it  
was giving me what looked like permission errors but it was really a  
sqlite version conflict. Hope that helps.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 29, 2007, 9:47pm UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609/3 "2007-11-29T21:47:32Z")

</div>

Oddly enough, I get the same error if the db, straw.db, is entirely  
missing!

Thanks for the info about the versions.

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 30, 2007, 6:21am UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609/4 "2007-11-30T06:21:03Z")

</div>

On Thu, 29 Nov 2007 10:15:48 -0600, Greg D. wrote:

> I had this problem once a while ago. My Ruby had sqlite version 2  
> support instead of version 3 or something like that. My point is it was  
> giving me what looked like permission errors but it was really a sqlite  
> version conflict. Hope that helps.

I have no idea what the problem was, but the solution was to not create  
the db myself but to have the migration do it (and the rails command  
create the database.yml automagically!):

thufir@arrakis ~/rubyCode $  
thufir@arrakis ~/rubyCode $ cat sqLiteStraw.rb  
require ‘fileutils’  
require ‘sqlite3’

FileUtils.rmtree ‘straw’  
system(“rails straw --database=sqlite3”)  
FileUtils.cd(‘straw’, :verbose =\> true)

##############################################

system(“script/generate migration feeds”)  
system(“script/generate migration categories”)  
system(“script/generate migration items”)  
system(“script/generate migration nodes”)

##################################################

FileUtils.rm ‘db/migrate/001\_feeds.rb’, :force =\> true  
\_001\_feeds = File.open(‘db/migrate/001\_feeds.rb’, ‘w’)  
\_001\_feeds.puts "  
class Feeds \< ActiveRecord::Migration  
def self.up  
create\_table :feeds do |table|  
table.column :title, :string  
table.column :location, :string  
table.column :category\_id, :integer  
end  
end  
def self.down  
drop\_table :feeds  
end  
end"  
\_001\_feeds.close

################################################

FileUtils.rm ‘db/migrate/002\_categories.rb’, :force =\> true  
\_002\_categories = File.open(‘db/migrate/002\_categories.rb’, ‘w’)  
\_002\_categories.puts "  
class Categories \< ActiveRecord::Migration  
def self.up  
create\_table :categories do |table|  
table.column :parent\_id, :integer  
table.column :title, :string  
end  
end  
def self.down  
drop\_table :categories  
end  
end"  
\_002\_categories.close

########################################

FileUtils.rm ‘db/migrate/003\_items.rb’, :force =\> true  
\_003\_items = File.open(‘db/migrate/003\_items.rb’, ‘w’)  
\_003\_items.puts "  
class Items \< ActiveRecord::Migration  
def self.up  
create\_table :items do |table|  
table.column :title, :string  
table.column :feed\_id, :integer  
table.column :is\_read, :integer  
table.column :link, :string  
table.column :pub\_date, :string  
table.column :description, :string  
end  
end  
def self.down  
drop\_table :items  
end  
end"  
\_003\_items.close

########################################3

FileUtils.rm ‘db/migrate/004\_nodes.rb’, :force =\> true  
\_004\_nodes = File.open(‘db/migrate/004\_nodes.rb’, ‘w’)  
\_004\_nodes.puts "  
class Nodes \< ActiveRecord::Migration  
def self.up  
create\_table :nodes do |table|  
table.column :obj\_id, :string  
table.column :norder, :string  
table.column :type, :string  
end  
end  
def self.down  
drop\_table :nodes  
end  
end"  
\_004\_nodes.close

#############################################

system(“rake db:migrate VERSION=0”)  
system(“rake db:migrate”)

##########################################

system(“script/generate scaffold feed”)  
system(“script/generate scaffold category”)  
system(“script/generate scaffold item”)  
system(“script/generate scaffold node”)

##########################################

FileUtils.rm ‘app/models/feed.rb’, :force =\> true  
modelsFeed = File.open(‘app/models/feed.rb’, ‘w’)  
modelsFeed.puts "  
class Feed \< ActiveRecord::Base  
has\_many :items  
end"  
modelsFeed.close

#############################################

FileUtils.rm ‘app/models/item.rb’, :force =\> true  
modelsItem = File.open(‘app/models/item.rb’, ‘w’)  
modelsItem.puts "  
class Item \< ActiveRecord::Base  
belongs\_to :feeds  
end"  
modelsItem.close

#############################################  
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”  
puts “\t\t\thttp://localhost:3000/feeds”  
puts “\t\t\thttp://localhost:3000/items”  
puts “\t\t\thttp://localhost:3000/categories”  
puts “\t\t\thttp://localhost:3000/nodes”  
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”

system(“script/server webrick --environment=development”)  
thufir@arrakis ~/rubyCode $

-Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [November 30, 2007, 6:25am UTC](https://www.ruby-forum.com/t/permissions-for-an-sqlite3-db-rake-aborted/121609/5 "2007-11-30T06:25:43Z")

</div>

On Thu, 29 Nov 2007 10:15:48 -0600, Greg D. wrote:

> I had this problem once a while ago. My Ruby had sqlite version 2  
> support instead of version 3 or something like that. My point is it was  
> giving me what looked like permission errors but it was really a sqlite  
> version conflict. Hope that helps.

I have no idea what the problem was, but the solution was to not create  
the db myself but to have the migration do it (and the rails command  
create the database.yml automagically!):

thufir@arrakis ~/rubyCode $  
thufir@arrakis ~/rubyCode $ cat sqLiteStraw.rb  
require ‘fileutils’  
require ‘sqlite3’

FileUtils.rmtree ‘straw’  
system(“rails straw --database=sqlite3”)  
FileUtils.cd(‘straw’, :verbose =\> true)

##############################################

system(“script/generate migration feeds”)  
system(“script/generate migration categories”)  
system(“script/generate migration items”)  
system(“script/generate migration nodes”)

##################################################

FileUtils.rm ‘db/migrate/001\_feeds.rb’, :force =\> true  
\_001\_feeds = File.open(‘db/migrate/001\_feeds.rb’, ‘w’)  
\_001\_feeds.puts "  
class Feeds \< ActiveRecord::Migration  
def self.up  
create\_table :feeds do |table|  
table.column :title, :string  
table.column :location, :string  
table.column :category\_id, :integer  
end  
end  
def self.down  
drop\_table :feeds  
end  
end"  
\_001\_feeds.close

################################################

FileUtils.rm ‘db/migrate/002\_categories.rb’, :force =\> true  
\_002\_categories = File.open(‘db/migrate/002\_categories.rb’, ‘w’)  
\_002\_categories.puts "  
class Categories \< ActiveRecord::Migration  
def self.up  
create\_table :categories do |table|  
table.column :parent\_id, :integer  
table.column :title, :string  
end  
end  
def self.down  
drop\_table :categories  
end  
end"  
\_002\_categories.close

########################################

FileUtils.rm ‘db/migrate/003\_items.rb’, :force =\> true  
\_003\_items = File.open(‘db/migrate/003\_items.rb’, ‘w’)  
\_003\_items.puts "  
class Items \< ActiveRecord::Migration  
def self.up  
create\_table :items do |table|  
table.column :title, :string  
table.column :feed\_id, :integer  
table.column :is\_read, :integer  
table.column :link, :string  
table.column :pub\_date, :string  
table.column :description, :string  
end  
end  
def self.down  
drop\_table :items  
end  
end"  
\_003\_items.close

########################################3

FileUtils.rm ‘db/migrate/004\_nodes.rb’, :force =\> true  
\_004\_nodes = File.open(‘db/migrate/004\_nodes.rb’, ‘w’)  
\_004\_nodes.puts "  
class Nodes \< ActiveRecord::Migration  
def self.up  
create\_table :nodes do |table|  
table.column :obj\_id, :string  
table.column :norder, :string  
table.column :type, :string  
end  
end  
def self.down  
drop\_table :nodes  
end  
end"  
\_004\_nodes.close

#############################################

system(“rake db:migrate VERSION=0”)  
system(“rake db:migrate”)

##########################################

system(“script/generate scaffold feed”)  
system(“script/generate scaffold category”)  
system(“script/generate scaffold item”)  
system(“script/generate scaffold node”)

##########################################

FileUtils.rm ‘app/models/feed.rb’, :force =\> true  
modelsFeed = File.open(‘app/models/feed.rb’, ‘w’)  
modelsFeed.puts "  
class Feed \< ActiveRecord::Base  
has\_many :items  
end"  
modelsFeed.close

#############################################

FileUtils.rm ‘app/models/item.rb’, :force =\> true  
modelsItem = File.open(‘app/models/item.rb’, ‘w’)  
modelsItem.puts "  
class Item \< ActiveRecord::Base  
belongs\_to :feeds  
end"  
modelsItem.close

#############################################  
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”  
puts “\t\t\thttp://localhost:3000/feeds”  
puts “\t\t\thttp://localhost:3000/items”  
puts “\t\t\thttp://localhost:3000/categories”  
puts “\t\t\thttp://localhost:3000/nodes”  
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”

system(“script/server webrick --environment=development”)  
thufir@arrakis ~/rubyCode $

-Thufir
