All of those three can of course be installed via system package
manager. But that is a bit limiting option because of following
- System-wide install is less flexible, as typically it allows
only one version of those languages to be installed;
- Installing packages via dependency managers for those languages
(like Gem, Pyp or Npm) requires root permissions;
- Removal and updating version becomes more complicated;
- Allows having different version of a language for specific projects
that can only work with that version.
I use Ubuntu, most of this writing, but quite similarly it all
can be done in other OS'es as well. Local installation may actually
mean that we are installing a language support for one user, or
even we can install several versions of the same language for that
user, as opposed to system-wide global installation. However for doing
that we need some additional tools that will make this whole process
simpler. What these tools do is creating a fake environment, with its
path and environment variables and guide through language installation process.
Actually after installation a language locally, they are not really
used until there is a need to install additional specific version of
a language for specific project. The language itself gets installed into that
fake environment, and so all software dependencies. These fake environments
can be loaded whenever user needs. Now I am going to explain how this is done
in all these languages.
Install Ruby via RVM
RVM is a version manager for Ruby. Its goal is to provide a way to install
several versions of Ruby into same box. To install RVM itself we run:
\curl -sSL https://get.rvm.io | bash -s stable
By default it creates a fake environment in ~/.rvm directory. Ruby itself
is not installed at this point still. But we can switch into this newly created
Note: this will only load RVM environment for this non-login terminal session.
If we want use this environment all the time, we can add the command above to
our ~/.bashrc file.
To get a list of all installable rubies we run:
Now we can install Ruby V1.9.3
This may however ask for the root password for installing packages that are required
for locally installed ruby to run. After this we need to run:
And now we can select which of installed versions we want to use (
rvm list can give a hint):
And here it is, now we can run ruby, gem, and all the binaries installed via gem.
Install Python via Virtualenv
Virtualenv is a tool that creates fake Python installation environment.
I prefer installing it via package manager, as python is installed in Ubuntu by
sudo apt-get install python-virtualenv
And then I usually create an environment for each project:
virtualenv --python=python3 ENV
And then I can switch to this environment:
And it gives me a virtual python3 environment.
Install NodeJs via Nodeenv
Nodeenv is a virtual environment creator for NodeJs based on the same VirtualEnv.
To get it type:
Yes, it needs python but as I mentioned python is in any OS by default anyway.
To see available NodeJs versions:
And say we decided to install 0.11.9:
That will install NodeJs environment to ENV directory. To start using it:
Some more musings:
While it is still possible to add something like
to .bashrc, I am happy to get in those environments only when I need to work with specific
project, although its Even possible to create both Python
and NodeJs environments into the same ~/.ENV directory.
Because python is installed to all decent operating systems anyway, so I only create these
environments to manage project specific dependencies separately, thats even more true to
NodeJs as it is still not mature enough and some projects are really depending on
specific NodeJs version.
Would I use these fake environments on my production servers? Here my answer is NO.
Because for production I want prepare my system specifically to run one or another
service, and before going to production is good to test it in a virtual machine that
has exactly same configuration as production servers. Just to avoid surprises.
So I use these virtual environments just for development. It is also good idea to have a
virtual machine for every project. But that comes with a cost, and this is yet another story.
There are comments.