Reputation: 135
Code @db = SQLite3::Database.new 'db.db'
works perfectly with ruby-1.9.3-p194 and returns error with ruby-2.0.0-p353 (rvm 1.24.7):
wrong argument type nil (expected Hash) (TypeError)
I can't googling any solution.
UPD: There is no error with irb. Only with my own code:
# encoding: utf-8
require 'sqlite3'
class Model
attr_reader :files, :last
def initialize(dbPath = 'photo.db', tags = '', lastID = 0)
@tags = tags
@lastID = lastID
$log.debug() {"Loading database: #{dbPath}..."}
@db = SQLite3::Database.new dbPath
end
...
It produces this trace in log:
I, [2013-12-29T12:03:30.586180 #8961] INFO -- : ---===== S T A R T E D =====--- I, [2013-12-29T12:03:30.587922 #8961] INFO -- : Config /home/michael/Projects/Ruby/SPS/config.yml loaded D, [2013-12-29T12:03:30.588072 #8961] DEBUG -- : Loading database: /home/michael/.local/share/shotwell/data/photo.db... F, [2013-12-29T12:03:30.588207 #8961] FATAL -- : wrong argument type nil (expected Hash) (TypeError) /home/michael/Projects/Ruby/SPS/model.rb:11:in `initialize' /home/michael/Projects/Ruby/SPS/model.rb:11:in `new' /home/michael/Projects/Ruby/SPS/model.rb:11:in `initialize' /home/michael/Projects/Ruby/SPS/controller.rb:11:in `new' /home/michael/Projects/Ruby/SPS/controller.rb:11:in `initialize' ./main.rb:10:in `new' ./main.rb:10:in `'
Upvotes: 0
Views: 163
Reputation: 135
I fixed it with replacing in executable script #!/usr/bin/ruby
with #!/usr/bin/env ruby
.
Upvotes: 1