How do I fully remove a package from Elixir Phoenix ?
I found this article: TIL: How to remove unused deps from mix.lock in Elixir | Code Chronicles
However, I am not sure if it is the same thing.
Thank you!
How do I fully remove a package from Elixir Phoenix ?
I found this article: TIL: How to remove unused deps from mix.lock in Elixir | Code Chronicles
However, I am not sure if it is the same thing.
Thank you!
@wktdev can you describe what might be different between what you’re looking for and that article? I think the article is exactly answering your question.
The document is talking about the mix.lock file and doesn’t say the contents of the deps folder.
If I edit my projects mix.ex file to remove a dependency do I also have to manually remove its respective folder(s) from the deps folder? I assumed that if I want to remove a dependency there is a command I can run to do it cleanly.
I am asking because I am working with a someone on a project and they insist on removing tailwind. I want to remove it the “right way” whatever that means. I don’t want to manually do it while accidentally leaving artifacts scattered all over the place and wondering why an element is behaving weird.
edit
It looks like this might be it but again, not 100 percent positive. Not sure if I am supposed to “unlock” them first.
mix deps.clean --unused --unlock
I just ran the commands in the article to remove tailwind.
When I run the server I get this error per my suspicion that it doesn’t get cleanly removed.
You have configured application :tailwind in your configuration file,
but the application is not available.This usually means one of:
You have not added the application as a dependency in a mix.exs file.
You are configuring an application that does not really exist.
Please ensure :tailwind exists or remove the configuration.
Also, app.css still references tailwind.
There are artifacts all over the place.
EDIT
I commented out the tailwind config code and now I get this error:
[error] Task #PID<0.633.0> started from AppWeb.Endpoint terminating
** (UndefinedFunctionError) function Tailwind.install_and_run/2 is undefined (module Tailwind is not available)
Tailwind.install_and_run(:default, ["--watch"])
(phoenix 1.7.1) lib/phoenix/endpoint/watcher.ex:19: Phoenix.Endpoint.Watcher.watch/2
(elixir 1.14.3) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/2
Args: ["tailwind", {Tailwind, :install_and_run, [:default, ["--watch"]]}]
[error] Task #PID<0.634.0> started from AppWeb.Endpoint terminating
** (UndefinedFunctionError) function Tailwind.install_and_run/2 is undefined (module Tailwind is not available)
Tailwind.install_and_run(:default, ["--watch"])
(phoenix 1.7.1) lib/phoenix/endpoint/watcher.ex:19: Phoenix.Endpoint.Watcher.watch/2
(elixir 1.14.3) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
(stdlib 4.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Function: &Phoenix.Endpoint.Watcher.watch/2
Args: ["tailwind", {Tailwind, :install_and_run, [:default, ["--watch"]]}]
@wktdev right so removing it from the deps list removes the actual dependency, but it doesn’t remove the uses of that dependency in your code. That’s going to be a fair number of spots. You’ll need to remove it from config as you’ve seen. It also looks like it’s still in your config as a watcher somewhere.
I’ve looked all over. I can’t find it. It’s not in the endpoint file. Regardless, my question has been mostly answered.
I hope that my article was helpful to you. If you have something that you think the article need to explain better, please let me know, and I’ll improve them
I’m not sure if you found a solution for your problem. But basically, you need to remove the usage of the dependency from your codebase, so remove it from the mix.exs
and after that, you need to “update” your mix.lock
running the command mention in the article, to remove the unused dependencies.
I think the challenge in this case is that @wktdev doesn’t have an unused dependency, rather their code base actually uses the dependency in several places. Thus they need to not only remove it from mix.exs etc, but also remove the places where it is used in their code base.
Yes, if I start an app with a generator it uses tailwind. There is probably a way to generate without tailwind but I am not sure if that fixes the problem. Being able to work without tailwind per the update in 1.7.2 is the answer - but it’s in the future. As it stands, removal just feels messy an I am unsure how to make a clean break.
If you run mix phx.new
without any arguments, it will show you the help page from the Phoenix generator. In that case, you can provide --no-assets
flag and handle manually JS/CSS files.
But in the next release of Phoenix we’ll have the --no-tailwind
flag, that could fix your problem.
It says –no assets doesn’t include JS. I want to use LiveView and Pub/Sub web socket functionality. Curious if any (behind the scenes) JS needed for that functionality is omitted. I’ll fire up an instance and play with it.
I know I am really annoying but these details count and I default to assuming the most extreme.
In this commit @josevalim breaks --no-assets
into --no-esbuild
and --no-tailwind
flag. You can check for files that isn’t generated in case of provide an --no-tailwind
flag (the :css
template), and remove/edit them in your files. So, remove it from mix.exs
and run the mix deps.clean --unused --unlock
command.
(Or just use the -dev
version, but you probably will need some effort later to update it to a stable version)
The blog link is broken. Here is the updated link: TIL: How to remove unused deps from mix.lock in Elixir | Code Chronicles
Also, at least in my case, mix deps.unlock --unused --check-unused
didn’t unlock anything. It seems that in the latest version of mix, --check-unused
will supersede --unused
so you only want to use one or the other at a time.
Cheers!
You are looking for mix deps.clean --unlock --unused
.
Thanks for the link update! I forgot to update it here.
Have the @dimitarvp solved your issue?