Phoenix 1.8.0-rc.0 released!

I see, thanks for the clarification. I actually like the simplified version better as generated email and password management is something I like to tweak most of the time.

One thing that seems to have been forgotten in the generator update/refactor: the :current_password virtual field is not being used anywhere else in the codebase.

3 Likes

Thank you! remove unused current_password field by SteffenDE · Pull Request #6222 · phoenixframework/phoenix · GitHub

1 Like

Was taking the latest rc.2 and generators out for a spin today to learn scopes and can’t figure out how to modify the router.ex for the JSON routes so the scopes work.

Basically from a freshly generated project I ran:

mix phx.gen.auth Accounts User users
mix phx.gen.json Weather City cities name:string temperature:float

The instructions say:

Add the resource to the "/api" scope in lib/phx18_web/router.ex:

    resources "/cities", CityController, except: [:new, :edit]

Ensure the routes are defined in a block that sets the `:current_scope` assign.

I uncommented out the /api code from the router and tried to add the fetch_current_scope_for_user plug to the :api pipeline but that didn’t work and my tests are failing with ** (ArgumentError) session not fetched, call fetch_session/2

  pipeline :api do
    plug :accepts, ["json"]
    plug :fetch_current_scope_for_user  # added this line
  end

  # Other scopes may use custom stacks.
  scope "/api", Phx18Web do
    pipe_through :api

    resources "/cities", CityController, except: [:new, :edit]
  end

I’m sure I’m missing out on something very simple here… hoping someone can help?

Hey @tme_317,

the fetch_current_scope_for_user plug works by fetching the user from the session. You could fetch the session similar to how the browser pipeline does it, but for an API you typically have a separate authentication mechanism. The docs have a guide on API authentication that also shows how to assign the scope in that case: API Authentication — Phoenix v1.8.0-rc.2

3 Likes

I took the new generators out for a spin around the block.

I ran into the following issues in GH with dependabot on a fresh install:
(Repo is private but not that hard to reproduce.)

Dependabot failed to update your dependencies because there was an error evaluating your Elixir dependency files.

Dependabot encountered the following error:

** (ArgumentError) The module Phoenix.CodeReloader was given as a child to a supervisor but it does not exist
    (elixir 1.18.1) lib/supervisor.ex:797: Supervisor.init_child/1
    (elixir 1.18.1) lib/supervisor.ex:905: Supervisor.child_spec/2
    (elixir 1.18.1) lib/enum.ex:1714: Enum."-map/2-lists^map/1-1-"/2
    (mix 1.18.1) lib/mix/pubsub.ex:77: Mix.PubSub.listener_supervisor/0
    (mix 1.18.1) lib/mix/pubsub.ex:59: Mix.PubSub.start_listeners/0
    (mix 1.18.1) lib/mix/tasks/deps.loadpaths.ex:74: Mix.Tasks.Deps.Loadpaths.run/1
    (mix 1.18.1) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.18.1) lib/mix/tasks/loadpaths.ex:36: Mix.Tasks.Loadpaths.run/1

{"error":""}

Can you please try Elixir v1.18.3?

Also I do not get this error locally, it is just something that popped up in dependabot’s error log.

I am using the following in CI + asdf local:

ELIXIR_VERSION: '1.18.3'
OTP_VERSION: '27.3.3'

My dependabot yaml looks like:

version: 2

updates:
  - package-ecosystem: "mix"
    directory: "/"
    schedule:
      interval: "daily"

Should I pin that version in the mix file? (which is generated with elixir: "~> 1.15".
Not sure how to let dependant know what elixir version I am using for the project.

Maybe an alternative for now is to check for DEPENDABOT env var and do not add the listener in your mix.exs if that’s true.

1 Like

Really cool to see this support to daisyui. Makes a lot of sense to add it to Phoenix. :relieved_face:

Thanks, that did the trick!

def project do
  [
    listeners: listeners()
  ]
end

defp listeners do
  if dependabot?() do
    []
  else
    [Phoenix.CodeReloader]
  end
end

defp dependabot? do
  Enum.any?(System.get_env(), fn {key, _value} -> String.starts_with?(key, "DEPENDABOT") end)
end
1 Like

Just run phoenix 1.8 rc from curl https://new.phoenixframework.org/myapp | sh and faced with unstyled demo app. source code looks good, but app.css doesn’t contains tw styles. Am I wrong about something?

This script is a bit outdated (if you look in curl response it installs -rc.0 version). How about this command instead?

mix archive.install hex phx_new 1.8.0-rc.3

This should be much more flexible way as using mix task you can generate a new Phoenix app with your own name.

Similar problem with the manual install, I decided not to mention it as it might seem like I made a mistake

~/apps/examples [master ≡]$ mix archive.install hex phx_new 1.8.0-rc.3 --force
Resolving Hex dependencies...
Resolution completed in 0.009s
New:
  phx_new 1.8.0-rc.3
* Getting phx_new (Hex package)
All dependencies are up to date
Compiling 11 files (.ex)
Generated phx_new app
Generated archive "phx_new-1.8.0-rc.3.ez" with MIX_ENV=prod
* creating /home/max/.asdf/installs/elixir/1.18.3-otp-27/.mix/archives/phx_new-1.8.0-rc.3

and after create mix phx.new

My app definitely have styles. watchman would not fix that, but you should install it from your distribution package manager. Tailwind-like styles should be much below those (not sure why it’s like that). Looks like you have some issue with session cookies. Please try to remove them in your browser web tools and try to refresh.

I don’t see how session cookies can affect the performance of tw. I partially fixed up the styles by editing the page template, this got the compiler to work.


Similarly, if I make a change to the theme switching component, it is stylized

But server restart drops everything

Okay, that can’t be right. the v4 documentation says Detecting classes in source files - Core concepts - Tailwind CSS.

Tailwind will scan every file in your project for class names, except in the following cases:

Files that are in your .gitignore file
Binary files like images, videos, or zip files
CSS files
Common package manager lock files

not for this purpose, but to see how artifacts are collected, I decided to do git init and it worked. tw relies on the presence of gitignore or something. made a new project - same problem with styles, initiate git - it works

1 Like

Just for sure every error should be fixed to not investigate every possible side effect. Keep in mind that besides standards browsers like to behave differently and therefore it’s important every potential browser-specific issue.

Weird, it works for me without a git init. The .gitignore file exists in generated project, but I’m not sure that’s it …

I do not see how .git directory is supposed to help you, but I guess the .gitignore can. Please take a look at:

Maybe the Tailwind have a problem with number of watched files? I have no idea. As wrote I already tried generating project and it works out-of-the-box.

tks for this, I got the same error on dependabot and I was unaware it was because I upgraded to Phoenix 1.8.0-rc