Search code examples
rubybundlerasdf

Difference between asdf vs bundler


What is the difference between asdf and bundler?

asdf docs states that "it is a tool that can manage multiple language runtime versions on a per-project basis."

bundler states that it "provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed."

Is the difference the same as pyenv vs poetry for Python projects?

I can't grasp the difference and the need for both to be used in the same project. I may be missing the main difference between version vs dependency management.


Solution

  • asdf is used to manage different versions of the used programming languages. In the context of Ruby projects, it is used to decide if you want to run your project with, for example, Ruby 2.7.4, Ruby 3.0.3, or Ruby 3.1.1. Using such a ruby version manager (like asdf, rbenv, rvm) is extremely useful when you work on different Ruby projects at the same time and they depend on different Ruby versions or when you are in the process of upgrading a Ruby project to a newer version and you need to switch between versions a lot. Additionally, when checking in the Ruby configuration into your version control system you can make sure that all developers use the same versions.

    bundler on the other hand is used to define library dependencies of your application. Imagine your Ruby application uses the redis gem to connect to a Redis database, then you can use bundler to define what version of the redis gem you want to use in your application. This is important because different versions might have different APIs or only newer versions support required features, or a new version introduced a breaking change that your application is not able to handle yet. Additionally, bundler helps to solve nested dependencies, like, when your app depends on gems a and b, but those gems also depend on gem c but with slightly different requirements. Then bundler tries to find a version of the c gem that fulfills the dependency config of both gems a and b.

    Is the difference the same as pyenv vs poetry for Python projects? I am not familiar with the Python ecosystem. But from having a glance at the docs of pyenv vs poetry IMHO they solve a similar requirement.