Mix ash.gen.resource failing on new project

I first create a new ash project as follows:

#!/bin/bash
if [ -f .env ]; then
    export $(grep -v '^#' .env | xargs)
fi
# Enable command echo
set -x

mix archive.install hex phx_new

# add deps
packages=(
  "ash@github:ash-project/ash"
  "ash_postgres@github:ash-project/ash_postgres"
  "ash_phoenix@github:ash-project/ash_phoenix"
)

mix igniter.new $PROJECT_NAME \
  --install $(IFS=,; echo "${packages[*]}") \
  --with phx.new \
  --extend postgres \

I then create a resource as follows:

if [ -f .env ]; then
    export $(grep -v '^#' .env | xargs)
fi
#PROJECT_NAME_CAPITALIZED
PCN=\
$(echo "$PROJECT_NAME" | awk '{print toupper(substr($0,1,1)) substr($0,2)}')

# Enable command echoing
set -x

cd $PROJECT_NAME
mix ash.gen.resource $PCN.Support.Ticket \
    --default-actions read \
    --uuid-primary-key id \
    --attribute subject:string:required:public \
    --extend postgres

This leads to the following error:

% mix ash.gen.resource Helpdesk.Support.Ticket \
    --default-actions read \
    --uuid-primary-key id \
    --attribute subject:string:required:public \
    --extend postgres
** (ArgumentError) expected an Elixir module, got: "Helpdesk.Support"
    (elixir 1.17.1) lib/module.ex:1747: Module.split/2
    (igniter 0.3.11) lib/igniter/code/module.ex:384: Igniter.Code.Module.do_proper_location/2
    (ash 3.3.0) lib/mix/tasks/gen/ash.gen.domain.ex:27: Mix.Tasks.Ash.Gen.Domain.igniter/2
    (ash 3.3.0) lib/mix/tasks/gen/ash.gen.resource.ex:188: Mix.Tasks.Ash.Gen.Resource.igniter/2
    (ash 3.3.0) lib/mix/tasks/gen/ash.gen.resource.ex:34: Mix.Tasks.Ash.Gen.Resource.run/1
    (mix 1.17.1) lib/mix/task.ex:495: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.17.1) lib/mix/cli.ex:96: Mix.CLI.run_task/2
    /Users/albin/.asdf/installs/elixir/1.17.1-otp-27/bin/mix:2: (file)

If I’m not wrong, this setup was working until a few commits ago. Was working before Jul 24th if memory serves right.

Thank you for the report! Fixed in 3.3.1

1 Like

Not sure if this is related to the latest fix, but I’m throwing a lot of errors now when running the mix ash.setup command following along on the guide to manually add postgres as a data layer. I just updated the dependency to 3.3.1 to resolve this original error which I was experiencing as well.

 mix ash.setup
Getting extensions in current project...

11:58:24.303 [error] beam/beam_load.c(180): Error loading module 'Elixir.Mix.Tasks.Reactor.Install 2':
  module name in object code is 'Elixir.Mix.Tasks.Reactor.Install'



11:58:24.304 [error] beam/beam_load.c(180): Error loading module 'Elixir.Ash 2':
  module name in object code is 'Elixir.Ash'



11:58:24.319 [error] beam/beam_load.c(180): Error loading module 'Elixir.Reactor 2':
  module name in object code is 'Elixir.Reactor'



11:58:24.321 [error] beam/beam_load.c(180): Error loading module 'Elixir.Ash.ActionInput 2':
  module name in object code is 'Elixir.Ash.ActionInput'
......

However, the setup and migrations appear to run correctly.

:thinking: that is quite strange. I don’t think I’ve ever seen anything like that before
'Elixir.Mix.Tasks.Reactor.Install 2' is definitely not a module name we’d ever create.

1 Like

Strange.

In case anyone else sees this error, I ran:

mix deps.clean --all
mix deps.get
mix deps.compile

and was able to finally run mix ash.setup without the long list of errors.

1 Like

getting an error with --extend now:

mix ash.gen.resource $PCN.Support.Ticket \
  --default-actions read,create,update,destroy \
  --uuid-primary-key id \
  --attribute subject:string:required:public \
  --relationship belongs_to:representative:$PCN.Support.Representative \
  --timestamps \
  --extend postgres,graphql

** (Mix) Could not invoke task “ash.gen.resource”: 1 error found!
–extend : Missing argument of type keep

works when --extend is omitted

If I then try to do an extend on this resource after creation I get the following error:

albin@Albins-MacBook-Pro helpdesk % mix ash.patch.extend Helpdesk.Support.Ticket postgres
Issues during code generation
* Could not find module to extend: Elixir.Helpdesk.Support.Ticket

N.B. This is a fresh project so Support.Representative does not exist yet

:thinking: please open an issue on ash I will look into it this week.

1 Like