BartOtten
For my public libs I have created demo apps. During development the demo app should depend on the development version of the library; so I use path: ../my_lib. However, when the demo app is cloned by a user it should depend on the Hex version instead.
Currently I set an environment flag which toggles the location of the dependency, but it keeps nagging in my head: this should be easier. Maybe detecting the existence of a file not committed to Git..?
Anyone having a better idea?
Ps. Detecting :dev runtime environment is not gonna cut it, as the user will probably run the demo in :dev too.
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
sodapopcan
This may not work for you but taking inspiration from Doggo, I package the demo app alongside the library in the same repo. While there some annoyances around grepping and how some editor tools handle nested mix.exs, it’s generally really convenient for everyone: 1) You can simply leave the dep as
{:my_lib, path: ".."}in your demo’s mix.exs, 2) the demo repo is source controlled alongside the lib, and 3) when users only have to clone one repo to get everything.I can imagine this isn’t always viable so I’m also interested in other options.
Nicodemus
I do this in the demo for one of my projects, in “mix.exs”:
Or you can append an entire list to the end if you have multiple deps. The nice thing about “mix.exs” is that it’s code, and is executed every time you run
mix.sodapopcan
I didn’t do it this way because it feels wrong to reach out into an unsuspecting user’s filesystem to execute code (at least from an unsanctioned directory). While I’m fully aware it’s super edge case, you never know what people have on their machines. For example, maybe they clone the example app into a directory where a long time ago they were experimenting with a mix project with the same name as your lib. Confusion ensues. It’s certainly an option, but I wish there was a more “official” way.
D4no0
If you don’t like that option, you can always use a environment variable to achieve the same, the important point is as @Nicodemus mentioned: you can execute elixir code inside of
mix.exs, which is a very powerful concept.sodapopcan
@BartOtten already mentioned the env variable approach which I do like better. I’m certainly aware mix.exs is just code which I thought was implied by my saying I already considered @Nicodemus’s approach (well, same goes for checking an env var, really).
D4no0
Indeed, after reading it again I misunderstood the question.
Addressing your previous concerns, just opening a project with a LSP carries risk of executing stuff you are unaware of, especially since elixir metaprogramming allows execution of code at compile-time.
BartOtten
Current implementation is like this. I did commit an .envrc file which sets the path. It seems checking path existence is the only ‘fully native’ solution. Combining it with env override and a warning might hit the sweet spot.
D4no0
If the solution works without many hitches, what is inherently wrong with it?
I guess you could use a mix task to ask the user the default option before he starts the project, but I don’t see that as a much better approach.
BartOtten
Not much. But as I can imagine others having the same use case, I wondered if there would be a better way.
And because I rather have a minimum of helper apps (such as direnv).
BartOtten
—nvm—..