tschnibo

tschnibo

Dependencies: Version incompatibility - What is the way to go?

Hey :slight_smile:
Just spent a day on finding out how to handle dependency problems when I need two different versions of one package. I am aware that there is always the option to create my own package.

Nevertheless, what I ended up doing was:

  • forking the dependency which I need two versions of
  • branching it
  • rename the module using: GitHub - MainShayne233/rename: Rename your Elixir apps
  • commit to the new branch
  • in mix.exs add dependency from my fork with the specific branch and the original / different version separately

I guess for most people this is not really a challenge… first timers are always harder. Nevertheless I wanted to ask if there is a better way. (From the other entries here I don’t think so).
I don’t really like that I end up having a forked version without an other reason besides the renaming.

Is this such a rare case that one has/wants to do so?

Could one write maybe a @before_compile Macro or something similar in order to automatically rename some dependencies or keeping them “private” respectively?
Maybe based on an “alias” or “namespace” tag in the mix.exs file.

My guess is that this would lead to more complexity and therefore the “forking” approach is considered better. And I have no clue how this would work, just out of curiosity.
Cheers

Most Liked

tschnibo

tschnibo

fair :slight_smile: I use mssqlex in the “original” version which comes with db_connection v1.1 for sap-hana
(just because it works with only minor changes) and then the mssqlex_v3 package which depends on db_connection v2.0 for Microsoft-SQL… I only read on the DB’s. Internally I use mongdb at the moment.

hubertlepicki

hubertlepicki

Right. So there’s one more option but I am not sure if it’s any more less terrible than what you figured out. Maybe, maybe not. You could set up non-homogenous Erlang/Elixir cluster where one node has an app loaded on it that talks to sap-hana, and other node has deployed app that talks to microsoft-sql…

Again, I am not saying it’s a good solution as it’s got it’s own set of problems in set up like that, starting with way more complicated deployment scenario, but it would be an alternative to what you do.

tschnibo

tschnibo

Thank you for thinking through and for this idea!

Actually I might even sometimes have thought about something in this direction. But at the moment this would be “over my head” and maybe as you said complicated in another way. Especially for developing, I would need to run one app separately adding sort of an “API-Layer”. If I understand this correctly. Then again I would learn about nodes… :smiley:

I also had a look at umbrella projects, but they are explicitly no suited for that problem.

So the forks are maybe really “the way to go”. What I was thinking: could one write an slightly adapted compiler / compiler plugin which takes a mix.exs or config file entry and prepends / renames specific module names accordingly? I mean I just did the whole forking stuff, no real need right now. I am more just thinking if there could be a simple solution. The larger the ecosystem gets, the more such “dependency problems” can occur I assume. What strikes me is on one hand, that the problem can be solved by renaming a package and on the other hand that it is solved that way. But of course I see that every added complexity to core functions as compilation do make the whole thing more complicated…

Where Next?

Popular in Questions Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New

Other popular topics Top

fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New

We're in Beta

About us Mission Statement