{"id":20134506,"url":"https://github.com/gnebbia/package_management_for_scripting_languages","last_synced_at":"2026-03-06T03:31:48.547Z","repository":{"id":129499241,"uuid":"86557891","full_name":"gnebbia/package_management_for_scripting_languages","owner":"gnebbia","description":"A personal tutorial about package management for common scripting languages","archived":false,"fork":false,"pushed_at":"2018-07-28T15:10:48.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T22:29:43.677Z","etag":null,"topics":["notes","package-management","packagemanagement","pip","scripting-language","scripts","tutorial","virtualenv"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnebbia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-29T08:36:16.000Z","updated_at":"2018-08-19T23:48:38.000Z","dependencies_parsed_at":"2023-06-11T12:15:26.187Z","dependency_job_id":null,"html_url":"https://github.com/gnebbia/package_management_for_scripting_languages","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gnebbia/package_management_for_scripting_languages","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnebbia%2Fpackage_management_for_scripting_languages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnebbia%2Fpackage_management_for_scripting_languages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnebbia%2Fpackage_management_for_scripting_languages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnebbia%2Fpackage_management_for_scripting_languages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnebbia","download_url":"https://codeload.github.com/gnebbia/package_management_for_scripting_languages/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnebbia%2Fpackage_management_for_scripting_languages/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30160858,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T22:39:40.138Z","status":"online","status_checked_at":"2026-03-06T02:00:08.268Z","response_time":250,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notes","package-management","packagemanagement","pip","scripting-language","scripts","tutorial","virtualenv"],"created_at":"2024-11-13T21:09:45.837Z","updated_at":"2026-03-06T03:31:48.523Z","avatar_url":"https://github.com/gnebbia.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## Scripting Language Evironment Management Guide\n\nAnytime on our system we deal with a programming language, especially scripting languages,\nwe have to correctly manage environments, there are some conventions used by programmers\nuseful to install on the system different versions of the same programming language interpreter,\nfor example what if we want to install ruby 2.2 and ruby 2.3 ? Is this possible ?\nWhat if we want to install two environments of perl 5.22 but with different sets of library ?\nWhat if we want to install a certain program but do not want to install all the dependencies\nneeded to run the program on the system, but only locally ?\nThis guide tries to answer all these questions.\n\n### Python\n\nTo manage different versions of python we can use different things, i use pyenv,\nin order to manage packages we should use \"pip\", well by default when we install\npython we will have a much simpler package manager called \"easy_install\", so\nwe could use it to install pip and then use pip always. Notice that the \nrepository containing all the python packages is called PyPi, and this is\nequivalent to CPAN for Perl. Pip should always be used with user\nprivileges, and never with root/sudo. \nIf we have problems installing packages with user privileges, we can try\nforcing it by using the \"pip install --user packagename\" command, in practice\nwhen we normally use pip it should have the \"--user\" option enabled by \ndefault, but if this is not true, we just specify it.\n\nLet's see some basic pip commands:\n\n```sh\npip search keyword \n```\n\nthis searches for modules which are related to the specified keyword\n\n```sh\npip install moduleName\n```\n\ninstalls the specified module\n\nTo list currently installed modules\n\n```sh\npip list\n```\n\nOr:\n\n```sh\npip freeze --all\n```\n\nTo uninstall a module we do:\n```sh\npip uninstall moduleName \n```\n\n#### Installing different python versions\n\nI generally recommend to always use some kind of interpreter package manager,\nfor python a common choice is pyenv.\n\nPyenv allows us to not touch the operating system python interpreter and its\nenvironment.\n\nWhenever I am on a new machine I generally want to install pyenv in order to\nwork with python stuff.\n\nOnce pyenv is installed we can check the avaliable python versions to install\nwith:\n```sh\npyenv install --list \n```\n\nWhen we find the version we are interested in we can install it by ussuing a\nsimple:\n```sh\npyenv install 3.6.5 # or whatever version you like\n```\n\nTo list installed python versions we can issue:\n\n```sh\npyenv versions\n```\n\nWe can see that the python `system` version is also selectable (if we ever would\nneed it).\nNow we can select the python version globally on the system with:\n\n```sh\npyenv global 3.6.5\n```\n\nWe can also temporarily set for the local shell environment a python version by\nissuing a :\n```sh\npyenv local 3.6.5\n```\n\n#### Virtual Environments\n\nTo manage isolated python environments we can use virtualenv.\nThere are many wrappers around virtualenv, but my suggestion is\nto learn to use plain virtualenv, and only with practice maybe pass to\nsomething more complex, actually virtualenv is not that difficult.\nVirtualenv creates a folder which contains all the necessary executables to use the \npackages that a Python project would need.\nVirtualenv ships by default with python3, but not with python2.\n\nIn order to install virtualenv for python2 we do:\n```sh\npip install virtualenv \n```\n\nNow we cd to the directory project where we want to create the virtualenv:\n\n```sh\ncd my_project_folder \n```\n\n\n```sh\nvirtualenv env \n```\nor if we are using python3 we can just do:\n\n```sh\npython -m venv env\n```\n\nthis will create a python virtual environment called \"env\"\nnotice that we can give whatever name we like, a common convention\nis to just call the directory containing all the needed things \"env\".\n\nWe can be more specific and tell virtualenv which python executable to use:\n```sh\nvirtualenv -p /usr/bin/python2.7 env \n```\n\n\nthis will create a python virtual environment with a selected python version,\nalso remember in this case that if we are using pyenv to manage python versions,\nwe should include the full path to the local python version ~/.pyenv/###/###/###\n\nIn order to activate a virtual environment once we have the env directory\ncreated, we do:\n\n```sh\nsource env/bin/activate \n```\nnow we can install packages as usual and they will be isolated from the rest of\nthe python packages and python system packages.\n\nFor example we can install the famous `requests` package with a normal:\n```sh\npip install requests\n```\n\nRemember to put the entire \"env\" directory in a git ignore file, if\nwe are using git.\n\nWhen we are done working with the environment we can just do:\n```sh\ndeactivate\n```\n\nTo delete a virtual environment, just delete its folder. (In this case, it would be rm -rf env.)\nIn order to keep your environment consistent, it’s a good idea to “freeze” the current state of \nthe environment packages. To do this, run:\n\n```sh\npip freeze \u003e requirements.txt\n```\n\n\nLater it will be easier for a different developer (or you, if you need to re-create the environment) \nto install the same packages using the same versions:\n\n```sh\npip install -r requirements.txt\n```\n\nthere are other tools which simplify all this process, such as virtualenvwrapper and autoenv, which \nautomatically activates python environments anytime we cd into a virtualenv directory\nif we want something more similar to perlbrew or rvm we should use pyenv.\n\n\n### Perl\nTo manage different versions of perl we can use perlbrew or plenv, i use perlbrew\nThe only things to install on system perl is:\n\n```sh\ncpan -i App::perlbrew\n```\n\nthis will install perlbrew, this is the only program needed to install,\nwith system perl, or it may be even avoided by installing it manually\n\n```sh\nperlbrew init\n```\n\nthis command should be executed by each user which wants to use perlbrew\nfor zshells we should append to the .zshrc file the line:\nsource `~/perl5/perlbrew/etc/bashrc`\nthen it is adviced to stick with perlbrew to install everything one needs\nanother package used a lot once perlbrew is installed is cpanminus, to install it we do:\n\n```sh\nperlbrew install-cpanm \n```\n\nit is adviced to install cpanm from perlbrew for the different versions\n\n```sh\ncpan App:cpanminus\n```\n\nfor completeness, here we report the command a system wide cpnaminus\n\t\n\n```sh\ninstmodsh\n```\n\nthis will list currently installed modules on system perl\n\n\n```sh\nperlbrew available\n```\n\nlist available perl versions that may be installed\n\n```sh\nperlbrew install perl-5.24.0\n```\n\nthis install the specified perl version\nperlbrew supports two notations to denote perl versions:\n\t* long notation: \tperl-5.22.2\n\t* short notation: \t5.22.2\n\n\n```sh\nperlbrew list\n```\n\nlist currently installed perl versions\n\n```sh\nperlbrew switch perl-5.22.2\n```\n\nswitch to the specified perl version, this must be available in \"perlbrew list\", the switch\n\t\t\t\t\t\t\t\nchanges the default perl version\n\n```\nperlbrew use 5.22.2\n```\n\nthe use command changes the perl version only for the current terminal session\n\n```\nperlbrew list-modules\n```\n\nthis will list currently installed modules on user perl now the modules we view\nare the one installed on the perl versions listed with \"perlbrew list\"\nnotice that these are the equivalent of rvm \"global\" gemsets, so whichever\nmodule we install we are installing it globally even for different projects, \nso here we advice only to install fundamental modules, such as Modern::Perl \nor other modules which we commonly use in order to create different \ninstances we can create the so called \"lib\"s so we do:\n\n```sh\nperlbrew lib create default\n```\n\nin this case we created with the current perl version selected a lib called \"default\"\nwe can switch to this lib with\n\n```sh\nperlbrew switch 5.22.2@default\n```\n\nthis switches to the default environment o perl 5.22.2\nnow we can install modules and not be contamined with the other perl versions\n\n```sh\ncpanm Module::Name\n```\n\nthis will install the module\n\n```\ncpanm -U Module::Name\n```\n\nthis will remove the module\nto remove a lib environment we can do:\n\n```sh\nperlbrew lib delete 5.22.2@default\n```\n\nto search for packages, we can do the following things:\n\n```sh\ncpan \n# once inside we do \nreload index\n```\n\nthen we have to zgrep our 02package file, so we do:\n\n```sh\nlocate 02package\n```\n\nonce found the file we can do:\n\n```sh\nzgrep 'WWW' path/to/02package.gz\n```\n\nif we use this function a lot we could script a function or create an \nalias to search. We can store dependencies of a project by creating \na file with the various dependencies,for example:\n\n```sh \necho 'requires \"Mojolicious\";' \u003e\u003e cpanfile\n```\n\n```sh \necho 'requires \"Net::Frame::Device\";' \u003e\u003e cpanfile\n```\n\nnow if a user wants to install the dependencies, just needs to do:\n\n```\ncpanm --installdeps .\n```\n\n\n### Ruby\n\nTo manage different versions of ruby we can use rvm or rbenv, let's see something with rvm:\n\nIn order to list the available versions of ruby that can be downloaded:\n\n```sh\nrvm list known\n```\n\n\nNow from the list let's say we are interested in the version 2.3 of ruby, then we can install it with: \n\n```sh\nrvm install 2.3\n```\n\n\nNow we can view the locally installed versions of ruby we can do:\n\n```sh\nrvm list\n```\n\n\nLet's install another ruby version:\n\n```sh\nrvm install 2.2.4\n```\n\n\nIn order to switch to a specific version of ruby for the current session we do:\n\n```sh\nrvm use 2.2.4 \n```\n\n\nobviously the version must be one of the locally installed versions.\n\n\nIn order to list the available and currently selected gemsets for the current version of ruby we do:\n\n```sh\nrvm gemset list \n```\n\n\nwe can think about a gemset as a set of modules.\nFor example we could have for ruby 2.2 different gemsets, by default there are two gemsets: \n\t-default\n\t-global\n\n\nIn order to list all the current versions of ruby with various gemsets we do:\n\n```sh\nrvm list gemsets \n```\n\n \nthis can be very useful to get a big picture of the situation of various ruby environments\non the system, and we can even inspect for gemsets we don't use anymore.\n\n\nIn order to set the default version of ruby we do:\n\n```sh\nrvm use --default 1.9.3 \n```\n\n\nTo show the currently selected (and working) version of ruby in use we do:\n\n```sh\nrvm current \n```\n\n\nIn order to switch to the default ruby version we do:\n\n```sh\nrvm default \n```\n\n\n\nIn order to uninstall and remove the sources of a specific version of ruby we do:\n\n```sh\nrvm remove 2.3 \n```\n\n\nnotice that this will not remove or touch in any way any gemsets.\n\n\n```sh\ngem help commands\n```\n\nshow the available commands\n\n#### Install, Remove and Search for Packages\n\nTo install a gem (i.e. ruby name for module) we do:\n\n```sh\ngem install moduleName\n```\n\n\nIn order to list the locally installed gems for the current environment we do:\n\n```sh\ngem list --local\n```\n\n\nTo search for a package we do:\n\n```sh\ngem search keyword\n```\n\n\nTo search for a package using keywords we do:\n\n```sh\ngem search --details keyword\n```\n\n\nwe add details to each package, note that this operation takes longer.\n\nTo uninstall a module we do:\n\n```sh\ngem uninstall moduleName\n```\n\n\nTo search for specific modules we can even use regex:\n\n```sh\ngem search '^rails$'\n```\n\n\nthis will find only one match, against plain 'rails' so search accepts regexes.\n\n#### Installing a gemset only for a specific project\n\nThe first step involves choosing a version of ruby:\n\n```sh\nrvm use 2.3 \n```\n\n\nthen we create a new gemset for the selected ruby version:\n\n```sh\nrvm gemset create my_project_name\n```\n\n\nnow to check the current gemsets we do:\n\n```sh\nrvm gemset list\n```\n\n\nnow we should see our gemset in the list, we can select our gemset with:\n\n```sh\nrvm gemset use my_proj\n```\n\n\nnow we can install whatever gem we want, in case we want to delete the gemset we do:\n\n```sh\nrvm gemset delete my_proj\n```\n\n\nthis will delete the entire gemset called my_proj,\nremember that the global gemset is the set of packages which are installed in all others gemset\nso when we create a new gemset all the gem installed in the global gemset will be transferred\nto the new created gemset.\n\n\n#### Create Project Based Ruby Version and Gemset\n\nonce we have created a project dir with:\nmkdir my_own_proj; cd my_own_proj\nwe can now create two files, which will contain\ncorrespectively ruby version and ruby gemset name, so we do:\n\n\n```sh\necho \"2.3\" \u003e .ruby-version\n```\n\n\n```sh\necho \"my_own_proj\" \u003e .ruby-gemset\n```\n\n\nnow anytime we will cd to the directory we will get the\nan automatic change of ruby version and gemset, this is\nvery adviceable for mantaining projects etc...\n\nonce we had deleted the project we can execute:\n\n```sh\nrvm gemset delete ruby-2.3@my-own-proj\n```\n\n\nthis will delete the entire gemset.\n\n\n#### Uninstall RVM \n\nIn order to uninstall rvm we just execute:\n\n```sh\nrvm implode\n```\n\nmany other options are available, for example we can migrate gemsets and many other things,\nrefer to the official doc for additional infos.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnebbia%2Fpackage_management_for_scripting_languages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnebbia%2Fpackage_management_for_scripting_languages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnebbia%2Fpackage_management_for_scripting_languages/lists"}