polypush135

polypush135

Nimble_publisher and recompiling while running iex or mix

I have made a simple static site using nimble publisher and followed along with the tut from fly.io Crafting your own Static Site Generator using Phoenix · The Phoenix Files

That said I have a simular build() function as from in the tut that just simply compiles the markdown files using earmark and so on with heex and then writes the to a given dir via File.write!

I’ve noticed that if I start a iex session or even run a cowboy server that if I call said build function while in IEx that it will not write anything different from when it started.

If I call recompile after I’ve made a change to a .md file but before I run said build() then it works. I assume this is because the other markdown files are still in memory even though I’ve edited a file, until I recompile that new edit wont be in memory. This is my assumption.

All of that is a non issue when calling from a mix task in a separate terminal session and build can be recalled and works as expected. Only time I see an unexpected behavor is when running the command from in iex or from a genserver that was watching files.

My question is: Is this assumption correct and what can I do about it?

First 5 of 5 Posts Switch mode

andyleclair

andyleclair

Yes, I think since NimblePublisher is storing the posts as a module attr, you’d need to recompile. I just ran into this issue myself! I was trying to code up a filesystem watcher just as I’m assuming you are.

I solved this for now by using System.cmd("mix", ["site.build"]) instead of Mix.Task.run("site.build").

jswanner

jswanner

What if you used rerun/2 instead?

mudasobwa

mudasobwa

Creator of Cure

The issue is reenabling tasks was kinda flawed and had been fixed days ago. The following would do:

Enum.each(~w|compile compile.all compile.elixir|, &Mix.Task.reenable/1)
Mix.Task.run("site.build")

On trunk we now have Mix.Task.Compiler.reenable(compilers: compilers) which would do, too.

andyleclair

andyleclair

rerun/2 also didn’t work for me. it would work to run the mix tasks, but because of the recompile, it wouldn’t work. . @mudasobwa do you know when that’s going to hit a point release?

mudasobwa

mudasobwa

Creator of Cure

v1.19 here is a PR https://github.com/elixir-lang/elixir/pull/13771#issuecomment-2564704542 merged.

— All posts loaded —

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement