# How to install modules

**URL:** <https://discourse.haskell.org/t/how-to-install-modules/1363>\
**Category:** Learn\
**Created:** [August 12, 2020, 8:35am UTC](https://discourse.haskell.org/t/how-to-install-modules/1363 "2020-08-12T08:35:26Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![danidiaz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/danidiaz/32/92_2.png) [@danidiaz](https://discourse.haskell.org/u/danidiaz)\
**Post date:** [August 12, 2020, 3:23pm UTC](https://discourse.haskell.org/t/how-to-install-modules/1363/3 "2020-08-12T15:23:26Z")

</div>

Ensure that **cabal --version** is \>= 3.

In an empty folder, type

> cabal install --lib --package-env . random

That should create a file named **.ghc.environment.\<somemorestuff\>** in the folder.

In that same empty folder, start **ghci** :

> ghci

Some message like “Loaded package environment from…” should appear when starting.

Inside ghci, import `System.Random`.

> Prelude\> import System.Random

If, when installing the package, you omit the location of the package environment:

> cabal install --lib random

then it updates a _default_ package environment located _somewhere_ in your home directory.

With a bit of luck, **ghci** invocations should pick this default environment, too, but explicitly writing **–package-env .** is more foolprof.

Some relevant links:

- [the cabal install section of the Cabal User Guide](https://cabal.readthedocs.io/en/3.4/cabal-commands.html#cabal-v2-install).

- [the GHC User Guide on how package environment files work, and where do GHC and ghci look for them.](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#package-environments)

---

_[View the full topic](https://discourse.haskell.org/t/how-to-install-modules/1363)._
