alfredfriedrich
Hello again fine folks of the elixir community,
I am struggling to write a small mix install task with Igniter. Basically I want to create some files in the install task, but if I create a new mix project with igniter.new foo --install my_app no matter what I try, my task does not seem to get called.
I a nutshell this is what I am trying to do:
$ mix igniter.new my_app
$ cd my_app
$ mix igniter.gen.task my_app.install
Inside the my_app.install.ex file I changed the igniter(igniter) function to look like this:
@impl Igniter.Mix.Task
def igniter(igniter) do
# Do your work here and return an updated igniter
igniter
|> Igniter.create_new_file(Path.expand("lib/foo.ex"), foo_ex())
|> Igniter.add_notice("mix my_app.install finished.")
end
defp foo_ex() do
"""
defmodule MyApp.Foo do
end
"""
end
When I try to run the installer in a new mix project (with igniter.new --install or with igniter.new + igniter.install afterwards) I always get the message No proposed content changes! :
mix igniter.new dummy --install my_app@path:../../my_app --verbose
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/dummy.ex
* creating test
* creating test/test_helper.exs
* creating test/dummy_test.exs
Your Mix project was created successfully.
You can use "mix" to compile it, test it, and more:
cd dummy
mix test
Run "mix help" for more commands.
Fetching and compiling dependencies ✔
Updating project's igniter dependency:
Updating project's igniter dependency: ✔
installing igniter:
installing igniter: ✔
compiling igniter:
===> Analyzing applications...
===> Compiling telemetry
compiling igniter: ✔
setting up igniter:
setting up igniter: ✔
compiling my_app ✔
`my_app.install` ✔
The following installer was found and executed: `my_app.install`:
No proposed content changes!
Successfully installed:
* my_app
I also tried with a git URI instead of a local file URI for the dependency but same result.
When I call the mix my_app.install task directly from the my_app project I do get the desired output:
Igniter:
Create: lib/my_app/foo.ex
1 |defmodule MyApp.Foo do
2 |end
3 |
What do I miss? I am grateful for any pointers and hints.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zachdaniel
Make sure that your library has igniter as an optional dependency and see if that helps
you might need to blow away the build folder in any other project you’ve added this dep to to get it to pick up the dep change
alfredfriedrich
Same behaviour with
optional: true, withpath:and withgit:URIAs for the
builddirectory, I use a small test script the make sure I get a clean state:zachdaniel
Can I see specifically what the
mix.exslook like of the package you’re trying to install?alfredfriedrich
Sure, it is a stock mix project with igniter:
zachdaniel
You need to remove the
onlyand have it just beoptional: truealfredfriedrich
That did the trick, thanks a lot Zach, much appreciate your help!
In hindsight, I should have read the
:envpart on themix depstask documentation more thoroughly: