pfun

pfun

Using 1.7.0-rc.0 for some experiments and it quickly became obvious that while code reloading is working as usual in lib/<appname>_web and elsewhere in the app, it is not working in lib/<appname>. This is a vanilla/out of the box application. I added phx.gen.auth to have some more code to edit that really should cause a reload.

I have tried this with a couple different versions of Elixir and Erlang. I tried going back to 1.6 and confirmed it’s working fine there. Finally, I used a different laptop (tested MacOS 12.4 and 12.6) and the same thing was observed.

Anyone else seen this? Third-party confirmation would be appreciated as well!

Showing Posts 1 to 10

derpycoder

derpycoder

Try mix deps.compile file_system

It fixed the issue with live reload, for me, after I updated both Mac and Phoenix.

pfun

pfun OP

Unfortunately this had no effect. On the second machine I tried this on there was no elixir (or really any devtools at all) beforehand. Completely clean install of erlang/elixir/phoenix 1.7 rc0

Worth clarifying, also, that I’m not talking about ‘live reload’, but just basic code reloading like editing the generated user.ex from phx.gen.auth. Changing the code does not cause the server to reload this code so it just keeps running the old version (e.g. add require Logger and Logger.error("TEST") to user.ex while the server is running, and you will not see the log (or at least, I don’t).

kokolegorille

kokolegorille

You might check the live reload patterns in config/dev.exs ans adjust them…

This post might be helpful.

pfun

pfun OP

Thanks but again that is for live reload, when I’m talking about just basic code reloading. As in the Phoenix server knowing that you edited an elixir file and using the new version. Nothing at all to do with browser reloading :frowning:

pfun

pfun OP

If anyone would like to try to reproduce:

mix archive.install hex phx_new 1.7.0-rc.0
mix phx.new testapp && cd testapp
mix phx.gen.auth Accounts User users
mix deps.get && mix ecto.create && mix ecto.migrate
mix phx.server

Go to register a user and put in only 4 chars for password, say. You get a validation error as expected. Now go to lib/testapp/accounts/user.ex and add to validate_email function or similar, something like:

require Logger
Logger.error("\n\n\n*******************\nTESTING\n*************\n\n\n")

Hit submit button again in browser. I do not see my new log. Change text of log, hit button again – still no log. Restart the server and try again, log appears! Edit the log message again, hit button again, log text does not change.

babouinette

babouinette

I can say I have the same problem :smiley:

pfun

pfun OP

Well that’s… ‘good’? :sweat_smile:
Thanks for confirming!

beepbeepbopbop

beepbeepbopbop

Can you clarify whether or not you are using LiveView based authentication system? When you run mix phx.gen.auth Accounts User users, you are given the prompt:

An authentication system can be created in two different ways:
- Using Phoenix.LiveView (default)
- Using Phoenix.Controller only
Do you want to create a LiveVIew based authentication system? [Yn]

I can only assume that you are using LiveView and if that’s the case, I think I know why your changes to your user.ex file aren’t being reflected. If you check endpoint.ex, you can see that plug Phoenix.CodeReloader is specified. So every request to your dev server goes through this plug and runs Phoenix.CodeReloader.reload(ExampleWeb.Endpoint) for you. If you were to make your logger change and reload the page, this ought to work and your change honoured.

Now, this doesn’t work with LiveView since they are process based. Once your LiveView connection is mounted (as in your LV has successfully mounted in both calls), all changes will be pushed to the LV, and won’t go through the Phoenix.CodeReloader. You would need to update something your web directory, or run recompile in your iex session.

I am not absolutely sure that this is the case, but give it a go without LV and see if you can replicate the issue you have.

Rugged

Rugged

Did you lodge a git issue, as I think this would be good to have fixed before final release.

I couldn’t see it here, but maybe its already closed.

pfun

pfun OP

Yea, this is an interesting point. It is a liveview auth system. However having worked with liveview before I’ve never had a code reloading problem like this. I’m going to try it with a non-live auth right now – uno momento.

Sadly an out-of-the-box non-liveview auth system seems to fail on the register page with no "new" html template defined for TestappWeb.UserRegistrationHTML (similar for the login page).

Anyway, simply the fact that you see stuff like:

Rebuilding...
Done in 48ms.

when editing in <appname>_web and not in <appname> seems like a problem to me.

@Rugged yea I had considered doing that right off the bat, but also I tend to assume it’s me doing something wrong by default :laughing: were you able to confirm this behaviour yourself by any chance?

Where Next? Top

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
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
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
rahultumpala
Hello, I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
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
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge &amp; Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews