Hello everyone,
I’ve ran “mix phx.gen.auth” in my new project.
Unfortunately I get an error in VSCode about the created User struct. I haven’t touched anything. The error is the following:
(CompileError) MyApp.Accounts.User.struct/1 is undefined, cannot expand struct MyApp.Accounts.User. Make sure the struct name is correct. If the struct name exists and is correct but it still cannot be found, you likely have cyclic module usage in your code
This error occurs in the Accounts
module:
defmodule MyApp.Accounts do
import Ecto.Query, warn: false
alias MyApp.Repo
alias MyApp.Accounts.{User, UserToken, UserNotifier}
def register_user(attrs) do
%User{} # <---- ERROR HAPPENS HERE
|> User.registration_changeset(attrs)
|> Repo.insert()
end
The User is a simple Ecto schema…
defmodule MyApp.Accounts.User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
field :email, :string
field :password, :string, virtual: true, redact: true
field :hashed_password, :string, redact: true
field :confirmed_at, :naive_datetime
timestamps()
end
This is only an error in VSCode. The server is running fine so far.
I have the feeling that this error is blocking the linting because the linting and autocompletion doesn’t work properly for me in VSCode when I write tests or try to rename functions for example.
Oh I’m using Arch btw