PostgreSQL – Error in top level: flunt.entityError.Nodatabase

I am trying to fix an error I recently encountered while running the Vapor project.

It builds well, but when it runs, it crashes. This is my log:

fatal error: Error raised at top level: Fluent.EntityError.noDatabase: file /Library/Caches/com.apple.xbs/Sources/swiftlang /swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 184
Current stack trace:
0 libswiftCore.dylib 0x0000000100fe7cc0 swift_reportError + 132
1 libswiftCore. dylib 0x0000000101004f50 _swift_stdlib_reportFatalErrorInFile + 112
2 libswiftCore.dylib 0x0000000100fb3370 partial apply for (_assertionFailed(StaticString, String, StaticString, UInt, flags: UInt32) -> Never).(closure #1).(closure #1). closure #1) + 99
3 libswiftCore.dylib 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) -> A + 355
4 libswiftCore.dylib 0x0000000100fb32b0 partial apply for (_asser tionFailed(StaticString, StaticString, StaticString, UInt, flags: UInt32) -> Never).(closure #1).(closure #1) + 144
5 libswiftCore.dylib 0x0000000100dfb5b0 specialized specialized String._withUnsafeBufferPointerToUTF8
( (UnsafeBufferPointer) throws -> A) throws -> A + 124
6 libswiftCore.dylib 0x0000000100f57af0 partial apply for (_assertionFailed(StaticString, String, StaticString, UInt, flags: UInt32) -> Never).( closure #1) + 185
7 libswiftCore.dylib 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer
((UnsafeBufferPointer) -> A) -> A + 355
8 libswiftCore.dylib 0x0000000100dfae80 _assertionFailed( StaticString, String, StaticString, UInt, flags: UInt32) -> Never + 144
9 libswiftCore.dylib 0x0000000100e1e540 swift_unexpectedError_merged + 569
10 App 0x0000000100001ef0 main + 2798
11 l ibdyld.dylib 0x00007fff974375ac start + 1
Program ended with exit code: 9

I am using the VaporPostgreSQL package. This is my Package.swift:

import PackageDescription

let package = Package(
name: "mist",
dependencies: [
.Package(url: "https://github .com/vapor/vapor.git", majorVersion: 1, minor: 2),
.Package(url: "https://github.com/vapor/postgresql-provider.git", majorVersion: 1, minor: 1)
],
exclude: [
"Config",
"Database",
"Localization",
"Public",< br /> "Resources",
"Tests",
]
)

and main.swift:

import Vapor
import VaporPostgreSQL
import Auth
import HTTP

let drop = Droplet()
let auth = AuthMiddleware(user: User.self)

try drop.addProvider(VaporPostgreSQL.Provider.self)
drop.preparations.append(Post.self)
drop.preparations.a ppend(User.self)
drop.preparations.append(Site.self)
drop.middleware.append(auth)

let admin = AdminController()
var site = Site(name: "", theme: "")

if let retreivedSite = try Site.all().first {
site = retreivedSite
} else {
drop.get {req in
return Response(redirect: "http://localhost:8080/login")
}
}

drop .get {req in
return try drop.view.make("Themes/VaporDark/index", [
"posts": Node(node: JSON(Post.all().makeNode()) )
])
}

admin.addRoutes(to: drop)

drop.resource("posts", PostController())

drop.run()

My postgres version is 9.6.1

For some reason, VaporPostgreSQL will not be updated, I think this may be the problem I have tried steam xcode, steam construction and steam cleaning, but I cannot get the latest version.

enter image description here

I think the problem is here:

< p>

if let retreivedSite = try Site.all().first {
site = retreivedSite
} else {
drop.get {req in
return Response(redirect: "http://localhost:8080/login")
}
}

More specifically, Site.all() is called. After calling run( ) Before the command, we do not prepare the model. Therefore, to find the site before this point, you need to prepare the model manually.

Hope this helps!

I am trying to fix the error I recently encountered while running the Vapor project.

It builds well, but when it runs , It crashes. This is my log:

fatal error: Error raised at top level: Fluent.EntityError.noDatabase: file /Library/Caches/com.apple.xbs /Sources/swiftlang/swiftlang-800.0.58.6/src/swift/stdlib/public/core/ErrorType.swift, line 184
Current stack trace:
0 libswiftCore.dylib 0x0000000100fe7cc0 swift_reportError + 132
1 libswiftCore.dylib 0x0000000101004f50 _swift_stdlib_reportFatalErrorInFile + 112
2 libswiftCore.dylib 0x0000000100fb3370 partial apply for (_assertionFailed(StaticString, String, StaticString, UInt, flags: UInt32)-#1 Never).(closure).(closure 1).(closure #1) + 99
3 libswiftCore.dylib 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer
((UnsafeBufferPointer) -> A) -> A + 355
4 libswiftCore. dylib 0x0000000100fb32b0 partial apply for (_assertionFailed(St aticString, StaticString, StaticString, UInt, flags: UInt32) -> Never).(closure #1).(closure #1) + 144
5 libswiftCore.dylib 0x0000000100dfb5b0 specialized specialized String._withUnsafeBufferPointerToUTF8
((UnsafeBufferPointer ) throws -> A) throws -> A + 124
6 libswiftCore.dylib 0x0000000100f57af0 partial apply for (_assertionFailed(StaticString, String, StaticString, UInt, flags: UInt32) -> Never).(closure # 1) + 185
7 libswiftCore.dylib 0x0000000100dfb0a0 specialized specialized StaticString.withUTF8Buffer
((UnsafeBufferPointer) -> A) -> A + 355
8 libswiftCore.dylib 0x0000000100dfae80 _assertionFailed(StaticString, String, StaticString, UInt, flags: UInt32) -> Never + 144
9 libswiftCore.dylib 0x0000000100e1e540 swift_unexpectedError_merged + 569
10 App 0x0000000100001ef0 main + 2798
11 libdyld.dylib 0x00007fff974375ac start + 1
Program ended with exit code: 9

I am using the VaporPostgreSQL package. This is my Package.swift:

 import PackageDescription

let package = Package(
name: "mist",
dependencies: [
.Package(url: "https://github.com/ vapor/vapor.git", majorVersion: 1, minor: 2),
.Package(url: "https://github.com/vapor/postgresql-provider.git", majorVersion: 1, minor: 1 )
],
exclude: [
"Config",
"Database",
"Localization",
"Public",
"Resources",
"Tests",
]
)

and main.swift:

import Vapor 
import VaporPostgreSQL
import Auth
import HTTP

let drop = Droplet()
let auth = AuthMiddleware(user: User.self)

try drop.addProvider(VaporPostgreSQL.Provider.self)
drop.preparations.append(Post.self)
drop.preparations.append(User.self)
drop.preparations.append(Site.self)
drop.middleware.append(auth)

let admin = AdminController()
var site = Site(name: " ", theme: "")

if let retreivedSite = try Site.all().first {
site = retreivedSite
} else {
drop.get { req in
return Response(redirect: "http://localhost:8080/login")
}
}

drop.get {req in
return try drop.view.make("Themes/VaporDark/index", [
"posts": Node(node: JSON(Post.all().makeNode()))
])< br />}

admin.addRoutes(to: drop)

drop.resource("posts", PostController())

drop. run()

My postgres version is 9.6.1

For some reason, VaporPostgreSQL will not be updated, I think this may be part of the problem. I have tried steam xcode, steam construction and steam cleaning, but I cannot get the latest version.

enter image description here

I think the problem is here:

if let retreivedSite = try Site.all().first {
site = retreivedSite
} else {
drop.get {req in
return Response(redirect: "http://localhost:8080/login")
}
}< /pre>

More specifically, Site.all() is called. Before calling the run() command, we do not prepare the model, so to find the Site before that point, you need to prepare the model manually.

Hope this helps!

Leave a Comment

Your email address will not be published.