Python and Ruby is pre-installed in macOS, but ...
Just don't install anything into System's programming languages, unless you have a virtual environment. Also, you can manage Python and Ruby's versions.
For Python, pyenv and there is Virtual Environment, which is quite opinionated. I use poetry, though. I also tried to fit /.venv/
into the project folder, which requires additional settings.