Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mix cannot build a macro library used in another library when macro is called more than once in project modules #13699

Closed
shahryarjb opened this issue Jul 1, 2024 · 3 comments

Comments

@shahryarjb
Copy link
Contributor

shahryarjb commented Jul 1, 2024

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Elixir 1.17.1 (compiled with Erlang/OTP 27)

Operating system

MacOS 14.3.1 Intel

Current behavior

Imagine you have a project named user_managment and you want to install a dependency and a has a dependency which is a macro

In real case:

Create a mix new project

mix new user_management --sup

Put this library in you user_management mix.exs file

{:mishka_installer, "~> 0.1.0-alpha.1"}

As you see mishka_installer has {:mishka_developer_tools, "~> 0.1.6"} dependency inside itself which is macro

- user_management
- |___ mishka_installer
-      |_____ mishka_developer_tools

Error I get

==> user_management
Unchecked dependencies for environment dev:
* mishka_installer (Hex package)
  the dependency build is outdated, please run "mix deps.compile"
** (Mix) Can't continue due to errors on dependencies

Expected behavior

As you can see I use my macro in 2 places

If I delete one of them, my compiling error is fixed. it does not allow me to use it more than once

It should be noted if I install mishka_developer_tools directly in my project for example: user_management I can use it inside Unlimited modules and has no problem.

I sent a post in the forum, but after a thorough review and uninstallation and activation and deactivation of each line of the project, I was sure that this could be a bug in Elixir itself, so I created an issue for this purpose

Link: https://elixirforum.com/t/the-dependency-build-is-outdated-error-with-getting-lib-from-github-branch/64599/2

@josevalim
Copy link
Member

You are changing a compile_env flag at compile-time:

https://github.com/mishka-group/mishka_developer_tools/blob/6364fbc54f4c84b8b087857f6e13b13c3d84a742/lib/macros/guarded_struct/guarded_struct.ex#L1500

This makes it so Mix believes the build of your dependency stale because a compile env flag is changing.

@josevalim josevalim closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2024
@shahryarjb
Copy link
Contributor Author

@josevalim Sorry to wasted your time and pinging you again 🥹. you have any suggestion for this part of app you linked me what should i use instead of.
And where you can address me to read more about these problem and maybe add some doc for it
Thank you in advance

@josevalim
Copy link
Member

I have pushed some new docs in main already. I am not sure what could be used instead, I didn’t try to fully understand what the code does, I only looked for the root cause of the bug. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants