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

Bug: CompileError lib/useful.ex:24: Plug.Upload.__struct__/0 is undefined 🔥 #52

Closed
nelsonic opened this issue Aug 15, 2023 · 5 comments
Assignees
Labels
awaiting-review An issue or pull request that needs to be reviewed BLOCKED Core team's HIGHEST priority, blocking critical work bug Something isn't working chore a tedious but necessary task often paying technical debt discuss Share your constructive thoughts on how to make progress with this issue help wanted Extra attention is needed priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies user-feedback Feedback from people using the App

Comments

@nelsonic
Copy link
Member

As noted by @LuchoTurtle in dwyl/mvp#406 and now confirmed in our other projects that use the Useful package: https://github.com/dwyl/gogs/actions/runs/5863993387/job/15898337199#step:8:51
image

== Compilation error in file lib/useful.ex ==
Error: ** (CompileError) lib/useful.ex:24: Plug.Upload.__struct__/0 is undefined, 
cannot expand struct Plug.Upload. 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
could not compile dependency :useful, "mix compile" failed. 
Errors may have been logged above. 
You can recompile this dependency with "mix deps.compile useful", 
update it with "mix deps.update useful" 
or clean it with "mix deps.clean useful"
    expanding struct: Plug.Upload.__struct__/0
    lib/useful.ex:24: Useful.atomize_map_keys/1

We either need to add Plug as dependency, not just :dev and :test the way it is now:
https://github.com/dwyl/useful/blame/35278cfb0c697cab555becfcc27ccf46731e61ee/mix.exs#L47-L48

OR we need to define our own "dummy" Struct.
But since the Useful package is used in at least one Elixir project that isn't a Phoenix App,
I think we won't have any other choice but to make Plug a dependency. 💭
Let's see how we can do this efficiently. 👌

@nelsonic nelsonic added bug Something isn't working help wanted Extra attention is needed BLOCKED Core team's HIGHEST priority, blocking critical work chore a tedious but necessary task often paying technical debt priority-1 Highest priority issue. This is costing us money every minute that passes. discuss Share your constructive thoughts on how to make progress with this issue T25m Time Estimate 25 Minutes user-feedback Feedback from people using the App technical A technical issue that requires understanding of the code, infrastructure or dependencies labels Aug 15, 2023
@nelsonic
Copy link
Member Author

I thought a good starting point for trying to understand this is to search for Plug.Upload in our imgup project that uses this struct: https://github.com/search?q=repo%3Adwyl%2Fimgup%20Plug.Upload&type=code

image

But sadly it was not insightful. 💭

@nelsonic
Copy link
Member Author

The version of Plug being used by Phoenix at the time of writing is 1.14:
https://github.com/phoenixframework/phoenix/blob/e095f23ff62efb2f8c1205b0cc67bfacd80b11ed/mix.exs#L73

So I'm replacing:

useful/mix.exs

Line 48 in 35278cf

{:plug, "~> 1.10", only: [:dev, :test]}

with:

{:plug, "~> 1.14"}

And will alias the Plug.Upload Struct in the useful.ex file.

@nelsonic
Copy link
Member Author

Aliasing the Plug.Upload Struct does not appear to be used:

image

Going to remove it. ✂️

@nelsonic
Copy link
Member Author

Patch Package published to https://hex.pm/packages/useful/1.12.1 📦
Tested in: dwyl/gogs#75
No longer has compilation error.

PR: #53 :shipit:

@nelsonic nelsonic moved this to ⏳Awaiting Review in dwyl app kanban Aug 15, 2023
@nelsonic nelsonic added the awaiting-review An issue or pull request that needs to be reviewed label Aug 15, 2023
LuchoTurtle added a commit that referenced this issue Aug 15, 2023
@LuchoTurtle
Copy link
Member

Closing, as #53 was merged.

@github-project-automation github-project-automation bot moved this from ⏳Awaiting Review to ✅ Done in dwyl app kanban Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review An issue or pull request that needs to be reviewed BLOCKED Core team's HIGHEST priority, blocking critical work bug Something isn't working chore a tedious but necessary task often paying technical debt discuss Share your constructive thoughts on how to make progress with this issue help wanted Extra attention is needed priority-1 Highest priority issue. This is costing us money every minute that passes. T25m Time Estimate 25 Minutes technical A technical issue that requires understanding of the code, infrastructure or dependencies user-feedback Feedback from people using the App
Projects
Status: Done
Development

No branches or pull requests

2 participants