Using Modules in Fedora
Modularity is a mechanism of making multiple versions of software available to your system.
Modules are special package groups usually representing an application, a language runtime, or a set of tools. They are available in one or multiple streams which usually represent a major version of a piece of software, giving you an option to choose what versions of packages you want to consume.
To simplify installation, modules usually define one or more installation profiles that represent a specific use case. For example a server
or a client
profile in a database module.
And because having too many choices might be overwhelming, Fedora ships with a set of module defaults — so you only need to make choices when desired.
Finally, because big changes are not always welcome, Modularity has been built in a way it can be basically invisible to the user. The usual installation commands continue to work — so packages with a default stream can be installed the same way as before regardles of them being modularized or not.
Discovering content
Listing packages
Packages available to the system can be discovered by the usual commands such as dnf search NAME
, dnf list NAME
, or by using the dnf repoquery QUERY
command for more complex queries. However, it is important to note that those commands will, apart from traditional packages, only list modular packages coming from a default or an enabled module stream.
Consuming content
Installing packages
Packages can be installed the usual way by running the dnf install NAME
command. Any traditional package, or a modular package coming from a default or an enabled module can be installed this way.
Packages from other module streams can be consumed by either enabling a module stream and then installing individual packages, or by installing a module directly.
Enabling modules
To enable a module stream and make its packages available for installation, run the following command:
$ dnf module enable NAME:STREAM
For example, to make Node.js 8 packages available for installation, run:
$ dnf module enable nodejs:8
Packages from enabled module streams can be then installed by the dnf install NAME
command.
Installing modules
To install a module, use one of the following commands. Not specifying a stream or a profile causes DNF to choose the default. However, not every module has a default stream or default profile.
$ dnf module install NAME $ dnf module install NAME:STREAM $ dnf module install NAME/PROFILE $ dnf module install NAME:STREAM/PROFILE
For example, to install the Node.js 8 runtime and the client tooling of the default stream of MongoDB, run:
$ dnf module install nodejs:8 $ dnf module install mongodb/client
Switching module streams
Switching streams is a risky operation that might not be always supported in packages, especially downgrades. |
Switching to a different stream than the one that is installed on a system is a two-step process. First, the current stream needs to be reset causing it not to be enabled anymore — this will however keep its packages installed. Second, a new stream needs to be installed.
$ dnf module reset NAME $ dnf module install NAME:STREAM
For example, to switch from Node.js 8 to Node.js 10, run:
$ dnf module reset nodejs $ dnf module install nodejs:10