BeacoHealthPublic
I want to auto compile/reload/hotswap the Elixir server side code whenever a file changes. For example, reload the controller, or reload the app inside the business logic/contexts section. How do you setup the config.
Here is how I have setup the config in the dev.exs section inside the config folder:
config :discuss, DiscussWeb.Endpoint,
reloadable_compilers: [:gettext, :phoenix, :elixir],
reloadable_apps: [:ui, :backend]
of course, if I change the code inside one of the controllers, it doesn’t work. How do you do this?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
NobbZ
The hotcode reloader is meant for development only. It only watches source files in the project directory, nothing else.
In production there is usually no need to watch sources, as you usually do not replace single source files, but the application as a whole.
If though those files are some data files, then I’m not sure why you want to reload a controller…
Usually there are better means of communication inside the application or with external applications than the local file system.
BeacoHealthPublic
Hi I mean in dev.
I’ve just discovered that the phoenix code reloader does work… it just doesn’t work when I edit the controller.ex files in vscode…
Have no idea why… It even happens when no plugins are installed.
Its as if vscode saves the file under some format which elixir doesn’t like.
If you wish to reproduce this, its easy. Download vscode, make a new elixir project. try editing some .ex file like UserController.ex, refresh the page, notice that the page doesn’t get updated.
NobbZ
So you want to use it for development? Okay, your intial post read as if you want to use the code reloader in production.
Since the code reloader works for me quite fine, and I do use VScode(ium), I have to ask what operating system you use and if you have installed the proper filesystem tools to make filewatches possible at all. Otherwise the reloader will fallback into a “polling” mode, which scans the filesystem only every few seconds and is inherently slow compared to proper watches.
Having said that, there are still files left the reloader refuses to trigger a recompilation on. IIRC the endpoint and the routes as well as changes at the
mix.exsorconfig/*.exswont trigger a reload, as the require a restart anyway.Last but not least, newly added files won’t trigger a reload as well, only files that existed when you started the server.
BeacoHealthPublic
so I am on ubuntu 18.04 and vscode version 1.35.1, I tested it by modifying the router.ex file. I tried both with ElixirLS plugin enabled and disabled, and I do have inotify-tools installed.
I tried it with atom editor and the atom editor works… not sure what specifically is going on with VScode, it has nothing to do with the plugins.
I also tried changing MIX_ENV=test then running the compile, as suggested by several posts, this did not solve the problem.
Lastly on my system, I have an issue with recompile. I think this recompile error is related to the above problem AND its easier to reproduce
so if you create a new project: mix new foo
Then open that project in vscode file → open → foo
Then inside the integrated terminal, do iex -S mix
then do recompile → answer is :noop (as expected because iex -S mix compiles your files)
BUT!
if you change something in an ex file in the lib folder(for example, inside foo.ex inside the hello world function, change :world to “hi there!”, then save it with vscode
THEN inside the integrated terminal do recompile
it shows :noop! when it should show :ok
This is definitely caused by vscode because if I perform the above steps in atom or in terminal(using gedit as the file editor) it show :ok instead of :noop.
NobbZ
When you run
iex -S mixthen afaik the reloader won’t be started (AFAIR not even the server), you need to runiex -S mix phx.serverto actually start phoenix and related tools…BeacoHealthPublic
my mistake, I didn’t communicate what I was trying to say well enough.
I am talking about 2 issues I have. The first issue is the phoenix server does not auto reload the code. But I have a 2nd separate issue. This issue is, inside a normal project(not a phoenix project) if I try the recompile command it show :noop instead of :ok(it shows noop even when it should show ok. i.e. it shows noop even while ex files have been edited). I think the second issue is related to the first issue. I think the first issue is caused by the second issue. I think if the 2nd issue was resolved, the first issue would be resolved. Even though the 1st issue and the 2nd issue are completely separate, independent issues that I have.
NobbZ
I have never experienced such issues. Are you strictly sure that the code you edit and the
iexsession you start are in the same project?lud
Hello, I have a similar problem of code reloading : when I edit
jsoreexfiles, the reload works, but not when I edit a controller. Any idea ?I am using Sublime Text and Mac OS
NobbZ
How does your live reload configuration looks like? per default it does only relead on static assets and templates.
lud
That was it, sorry for the newbish question, I thought watching the controllers was a default (didn’t it use to ?) so I did not check the docs.
Thank you !
Does phoenix “know” that it must wait for the new code to be loaded before sending the page reload message ?