Genie Discord forum
I wrote a module, placed in the
lib folder, and used by the controllers. In order to simplify it a bit, I cutout a part of its code to a separate
.jl file, and left a
include("file.jl") in the module. Now I get weird errors that seem to indicate that the included code in the file is evaluated before the code in the module...? I even tried
Base.include(MyModule, "file.jl") but to no avail...
It's weird cause everything seems to actually work, except I get an error:
julia> using GenieFramework; Genie.loadapp(); up() ██████╗ ███████╗███╗ ██╗██╗███████╗ ███████╗ ██╔════╝ ██╔════╝████╗ ██║██║██╔════╝ ██╔════╝ ██║ ███╗█████╗ ██╔██╗ ██║██║█████╗ ███████╗ ██║ ██║██╔══╝ ██║╚██╗██║██║██╔══╝ ╚════██║ ╚██████╔╝███████╗██║ ╚████║██║███████╗ ███████║ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚═╝╚══════╝ ╚══════╝ | Website https://genieframework.com | GitHub https://github.com/genieframework | Docs https://genieframework.com/docs | Discord https://discord.com/invite/9zyZbD6J7H | Twitter https://twitter.com/essenciary Active env: DEV Loading libsERROR: UndefVarError: `SVector` not defined Stacktrace:  top-level scope @ ~/new_projects/dancing queen/project/app/lib/detection.jl:1 in expression starting at /home/yakir/new_projects/dancing queen/project/app/lib/detection.jl:1 [ Info: 2023-08-29 14:09:23 Watching ["/home/yakir/new_projects/dancing queen/project/app"] Ready! ┌ Info: 2023-08-29 14:09:27 └ Web Server starting at http://127.0.0.1:8000 Genie.Server.ServersCollection(Task (runnable) @0x00007f8be6c7d780, nothing) julia> [ Info: 2023-08-29 14:09:27 Listening on: 127.0.0.1:8000, thread id: 3
and here are the first few lines in my module:
module Cameras using Dates, LinearAlgebra using Observables, AprilTags, StaticArrays using VideoIO # remove Base.include(Cameras, "detection.jl") # or include("detection.jl")
using ... **StaticArrays** before the
Does it work if you manually include your app with
include("app.jl")and start the server with
Yes, it does.
Then this is be a conflict with Genie's automatic loading of files in the "/lib" folder
I usually include files manually , but it's true that with loadapp() the lib/ folder is automatically available and you can just do
ok, I'll stick to include("app.jl") from now on then, and avoid loadapp
Best way would be to fix the imports in the module. loadapp enables features like logging and hot reloading which are pretty useful
"fix the imports in the module" but how? The link only explains how to include a module into the app, which I'm already doing and it works. But I want to include a file with some code into a module that is already included into the app. and that doesn't work.
Forgive me, I reread my response here and it comes through as quite harsh. It was unintended, sorry.
Following is an illustration of what I mean:
app ├── app.jl ├── controllers │ └── ... ├── lib │ ├── MyModule.jl │ └── file.jl ├── Manifest.toml ├── pages │ └── ... └── Project.toml
MyModule.jl I have:
module MyModule include("file.jl") end
file.jl is just:
fun(x) = 2x
That's okay @yakir12 🙂
autoloadfunction that can be set to watch files in a folder with Revise.jl. This is automatically set for
lib/. I suppose this is a
Reviselimitation, as code imported via a standard
includecannot be hot reloaded
Another possiblity is that this is due to the order in which the modules are loaded. It is possible to change this order, so that you could load first the .jl file and then the module
Awesome! From your link I learned about
.autoload_ignore, so I just plumped a
.autoload_ignore file in the
lib folder and now
julia> using GenieFramework; Genie.loadapp(); up()
just works! Thank you.