# Installing different version of dev packages (node, python, ruby, etc.) on freebsd



## srey (Mar 5, 2022)

Hi,

As developper coming from Ubuntu,
i'm using lots of different "package manager" for different langages...

To manage the potential conflict that arrive with different version of langage and dependencies on the same system, this is more and more common to use "*shim*" redirection that help dev to manage locally (by folder) or globally all this mess.

- nodenv for node
- jenv/sdkman for java
- pyenv for python
- rbenv for ruby
- etc.

Recently i see that ASDF-VM or ASDF (http://asdf-vm.com/) could simplify this process, wrapping each of them with one common specification and plugins.
There is also sdkman : https://sdkman.io/

*As a newcomer* *into freebsd,  *i first search if ports exist to install, without success.

So, what's the best thing to do in this situation* : *
- continue to use shim manager for each langage, compiling each if ports don't exist.
- try to compile locally one of them (adsf or sdkman) then write a ports for community ?

I'm also planning to do that using Ansible.

Thanks,


----------



## hbsd (Mar 5, 2022)

Hi srey  and welcome to FreeBSD, sorry I didn't see your topic.
I work with Python/Ruby. I use virtualenv for python and rbenv for ruby.
Sorry I don't know much about Node and Java but it seems you can use nodeenv for Node.js. But for what I know:

You can install virtualenv just with:
`pip install virtualenv`

Using virtualenv is so easy just go to your directory and use python version that you want to use (for example for python 3.9):
`virtualenv --python=/usr/local/bin/python3.9 .`

Then activate it:
`. bin/activate`

Install your software. for example:
`pip install django==4.0.2`

And I installed rbenv (full) this way:
`git clone https://github.com/rbenv/rbenv.git ~/.rbenv

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile

echo 'eval "$(rbenv init -)"' >> ~/.profile`

Now you can install ruby version that you want, but before you have to install bash:
`pkg install bash`

Then open your terminal and type these:
`bash

source ~/.profile`

It's time to install ruby (choose version that you want. for example 3.1.1):
`rbenv install -l

rbenv install 3.1.1

rbenv global 3.1.1`

packages can be installed with gem. for example:
`gem install rails`

Good luck.


----------



## hbsd (Mar 5, 2022)

srey said:


> *As a newcomer* *into freebsd, *i first search if ports exist to install, without success.


You can use packages or ports to install software.

Packages are software binaries that will install quickly.

Search for packages with `pkg search software_name` If that software exist then install with `pkg install software_name`.

Ports are are software sources which must be compiled.

Search for ports with `whereis software_name` then compile with  `cd /usr/ports/category/software_name/ && make install clean` (needs root access).


----------



## Phishfry (Mar 5, 2022)

I think you really need to use `pip` in only extreme cases and use packages if they exist.
Easy to forget about an old software version installed via pip. What if pip becomes 'infected'?
Best practice is to use FreeBSD provided software when possible.
Package management is a shining point. Package audit is supreme.
But for old or multiple versions of same software I would say use a jail for each.
An advantage is you can separate potentially vulnerable (old) software from your base system.


----------



## srey (Mar 6, 2022)

hbsd said:


> You can use packages or ports to install software.
> 
> Packages are software binaries that will install quickly.
> 
> ...



Thanks hbsd , for python i use pyenv + pipenv a lot, because pyenv you could install multiple version of python and after that with pipenv it's easy to install different different dependencies with virtualenv, and new pip on each instance.

I also use poetry (ex : https://dean-shaff.github.io/blog/python,/software,/poetry/2020/12/14/why-i-use-poetry.html )... because python packaging world is so much complicated...

I see pyenv, pipenv, poetry exist on freshports, so i will try to get information on this and compile my version using Ansible as recipe manager ...


----------



## srey (Mar 6, 2022)

Phishfry said:


> I think you really need to use `pip` in only extreme cases and use packages if they exist.
> Easy to forget about an old software version installed via pip. What if pip becomes 'infected'?
> Best practice is to use FreeBSD provided software when possible.
> Package management is a shining point. Package audit is supreme.
> ...



You're right, i don't want to use directly pip.
Python use virtual environment to encapsulate pip and dependencies (like jail for python env)

I'm starting to read about jail, but i don't know if it's possible to deploy one jail by virtualenv from python ? Anyone already try something like that ?


----------



## Alain De Vos (Mar 6, 2022)

It's best to keep only one version. If you need different versions you could for instance use jails for this.


----------



## srey (Mar 7, 2022)

Alain De Vos said:


> It's best to keep only one version. If you need different versions you could for instance use jails for this.



Is it possible and recommended to make a jail for each version of python/node/ruby/java ?


----------

