Can not get basic project with Leaf to work

Hello,

I am running Vapor 4 on macOS 11.5.1 and Xcode 13.2.1. I am trying to get the vanilla vapor project to run. I am using “vapor new helloVapor_fluent --branch macos10-15” to generate the project with vapor + fluent + postgres and it runs fine when tested with a browser. But when I add Leaf to the combo like “vapor new helloVapor_fluent_leaf --branch macos10-15”, I do not get the “It works” response in the browser but the message “{“error”:true,“reason”:“LeafError(file: "/Users/thomasha/Library/Developer/Xcode/DerivedData/helloVapor_fluent_leaf-giannuzawgcbaiabycfberigznpk/SourcePackages/checkouts/leaf-kit/Sources/LeafKit/LeafSource/LeafSources.swift", function: "searchSources(t:on:s:)", line: 73, column: 69, reason: LeafKit.LeafError.Reason.noTemplateExists("index"))”}” and the debugger in Xcode displays: " [ NOTICE ] Server starting on http://127.0.0.1:8080

[ INFO ] GET / [request-id: A655E26D-98F4-4C44-9E9F-A131B3588BCD]

[ WARNING ] LeafError(file: “/Users/thomasha/Library/Developer/Xcode/DerivedData/helloVapor_fluent_leaf-giannuzawgcbaiabycfberigznpk/SourcePackages/checkouts/leaf-kit/Sources/LeafKit/LeafSource/LeafSources.swift”, function: “searchSources(t:on:s:)”, line: 73, column: 69, reason: LeafKit.LeafError.Reason.noTemplateExists(“index”)) [request-id: A655E26D-98F4-4C44-9E9F-A131B3588BCD]"

Of course the “index.leaf” file is in the “Resources/Views” path. The same happens in my main project, where I use Leaf analog to chapter 14+15 of the book.
Any suggestions?

You need to set the custom working directory for the project. It should be explained in the book but you can see how to do it in the docs as well

1 Like

works like a charm! Thanks a lot. You are right, it is documented in the book in chapter 14, p305, paragraph “Rendering a page” at the end.