gpt4 book ai didi

ruby sqlite3 sinatra 无法执行 db :Migrate

转载 作者:行者123 更新时间:2023-12-02 07:38:55 24 4
gpt4 key购买 nike

我正在使用 w10 64 位

应用程序.rb

require 'rubygems'
require 'sinatra'
require "sinatra/activerecord"
require 'sqlite3/sqlite3_native'


class App < Sinatra::Base
#configuraciones
set :root, File.dirname(__FILE__)
set :session_secret, 'super secret'
set :public_folder, File.dirname(__FILE__) + '/public'
set :layout, 'views/layouts'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'data.db'
)
enable :sessions
#before all requests
before do
headers['server'] = 'Ruby, Ubuntu'
end

end

rakefile.rb

require "sinatra/activerecord/rake"
require 'sqlite3/sqlite3_native'
require 'sinatra'
require './app'

gem 文件

source "https://rubygems.org"

gem "sinatra"
gem "json"
gem 'sinatra-activerecord', '~> 2.0', '>= 2.0.9'
gem 'rake'
gem 'sqlite3'

所以当我尝试执行 db:migrate 时我无法执行此操作,sqlite3 版本 1.3.13执行命令

bundle exec rake db:migrate
rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

所以我不知道问题到底是什么,需要帮助

更新

我将 rakefile.rb 更改为仅需要“sqlite3”但知道我收到其他错误

rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

Caused by:
LoadError: cannot load such file -- sqlite3/2.5/sqlite3_native
C:/ruby/sinatra/Rakefile.rb:2:in `<top (required)>'

最佳答案

尝试从 rakefile.rb 中删除 sqlite3_native 并只需要 sqlite3

关于ruby sqlite3 sinatra 无法执行 db :Migrate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53297217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com