shahryarjb
How to add and install deps without stopping phoenix server (hex package)
I have written Need advice to implement custom extension and template installation in an elixir CMS post that I need your suggestion to improve my project. Still, I decided to separate some questions into different topics.
Is there a way when my application is running, I add some packages in my mix.exs without stopping the server, and it should be compiled and usable?
I searched about hot code reloading in Elixir, but I could not find anything about hex packages. I am using elixir 1.13+
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
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
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 10 of 25 Posts
shahryarjb
Any suggestions?
kokolegorille
Yes…
Don’t do it.
BTW It’s easy to check it is not possible, just try to edit mix.exs of a running server
hauleth
It is not possible as adding new dependency may require recompilation of other dependencies, and there is no way for Elixir to know that (it is knowledge that only Mix has).
LostKobrakai
The beam has means to load code at runtime. But that’s all it does: Load arbitrary code.
All the additional requirements like replacing running processes, dependency management and such are afaik still handled at compile time when building the release to update to. That’s the data in the appup file mentioned in places.
These points may not matter for plugins on a CMS. At best files loaded are completely independent of each other and have no compile time dependencies to each other, but there’s nothing in elixir or on the beam to enforce that at runtime.
dimitarvp
Wouldn’t this be possible with the new
Mix.installfacility? But I haven’t checked.crispinb
I’m pretty sure this is the correct advice:
As a thought experiment, there might be a convoluted and risky way. I’m not remotely suggesting you actually do this, but I’d be interested to hear from knowledgeable folk here about what I have right here (& not).
You can add dependencies at runtime using Mix.install (as commonly used in LiveBook).
But
Mix.installcan’t be used within a Mix project (it works by dynamically creating a new one). So you’d need to do something like host and run elixir scripts, maybe similarly to LiveBook (I don’t know how that works). But the packages installed within those scripts wouldn’t be available to regular Phoenix projects, which obviates the point. You could perhaps work around that by running scripts which each set up their own Phoenix-like pipeline (eg. as a starting point example phoenix.exs · GitHub). Or (more realistically perhaps) create a custom plugin API allowing the CMS’s Phoenix process to call on these added scripts functionality via message passing.[sorry @dimitarvp , didn’t mean to step on your toes]
shahryarjb
Unfortunately, I don’t know what developers want to create; create a hex package with many dependencies or no dependencies
My problem comes from when my user has no knowledge of elixir and just a user who want to use my CMS.
kokolegorille
It was a demo for You… to test that the server will complain when You modify the mix.exs file of a running server and reload the page.
shahryarjb
I think if I handle it with docker is better option instead of elixir side. And I think downtime is too low to know user 's site is down or not.
kokolegorille
You might have security problems if You allow users to load random modules.