Bugzilla (bugzilla.redhat.com) will be under maintenance for infrastructure upgrades and will not be available on July 31st between 12:30 AM - 05:30 AM UTC. We appreciate your understanding and patience. You can follow status.redhat.com for details.
Bug 1730807 - Behavior of dnf module remove
Summary: Behavior of dnf module remove
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 30
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jaroslav Mracek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-17 17:30 UTC by Jun Aruga
Modified: 2019-10-10 16:55 UTC (History)
10 users (show)

Fixed In Version: dnf-4.2.11-2.fc30
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-10-10 16:55:55 UTC
Type: Bug


Attachments (Terms of Use)

Description Jun Aruga 2019-07-17 17:30:18 UTC
Description of problem:

"sudo dnf module remove ruby:2.6/default" does not remove RPMs.
Only removing a mark of "[i]" in the result of ruby:2.6 of "dnf module list ruby". 
While "dnf module install" installs RPMs like "dnf install", "dnf module remove" does not remove RPMs like "dnf remove".

Is it intended behavior?

The manual for "dnf module remove" shows

https://dnf.readthedocs.io/en/latest/command_ref.html#module-command-label
> Remove installed module profiles, including their packages. In case no profile was provided, all installed profiles get removed.

Version-Release number of selected component (if applicable):
dnf-4.2.2-2.fc30.noarch

How reproducible:


Steps to Reproduce:
1. $ sudo dnf module reset ruby
2.

```
$ rpm -q ruby ruby-devel ruby-libs
ruby-2.6.3-120.fc30.x86_64
ruby-devel-2.6.3-120.fc30.x86_64
ruby-libs-2.6.3-120.fc30.x86_64
```

3.

```
$ sudo dnf module install ruby:2.6/default
...
Upgraded:
  ruby-2.6.3-120.module_f30+4422+f50e013d.x86_64                                              
  ruby-devel-2.6.3-120.module_f30+4422+f50e013d.x86_64                                        
  ruby-libs-2.6.3-120.module_f30+4422+f50e013d.x86_64                                         

Complete!
```

4.

```
$ rpm -q ruby ruby-devel ruby-libs
ruby-2.6.3-120.module_f30+4422+f50e013d.x86_64
ruby-devel-2.6.3-120.module_f30+4422+f50e013d.x86_64
ruby-libs-2.6.3-120.module_f30+4422+f50e013d.x86_64
```

5.

We see ([i] =) installed ruby:2.6 module.

```
$ dnf module list ruby
Last metadata expiration check: 1:23:33 ago on Wed 17 Jul 2019 05:55:14 PM CEST.
Fedora Modular 30 - x86_64
Name      Stream      Profiles        Summary                                                 
ruby      master      default         An interpreter of object-oriented scripting language    

Fedora Modular 30 - x86_64 - Updates
Name      Stream      Profiles        Summary                                                 
ruby      master      default         An interpreter of object-oriented scripting language    
ruby      2.5         default         An interpreter of object-oriented scripting language    
ruby      2.6 [e]     default [i]     An interpreter of object-oriented scripting language    

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
```

6.

```
$ sudo dnf module remove ruby:2.6/default
...
==============================================================================================
 Package               Architecture         Version               Repository             Size
==============================================================================================
Disabling module profiles:
 ruby/default                                                                                

Transaction Summary
==============================================================================================

Is this ok [y/N]: y
Complete!
```

7. See the result of `$ rpm -q ruby ruby-devel ruby-libs`.

Actual results:

```
$ rpm -q ruby ruby-devel ruby-libs
ruby-2.6.3-120.module_f30+4422+f50e013d.x86_64
ruby-devel-2.6.3-120.module_f30+4422+f50e013d.x86_64
ruby-libs-2.6.3-120.module_f30+4422+f50e013d.x86_64
```

Expected results:

```
$ rpm -q ruby ruby-devel ruby-libs
package ruby is not installed
package ruby-devel is not installed
package ruby-libs is not installed
```


Additional info:

Comment 1 Jun Aruga 2019-07-22 11:53:19 UTC
> Remove installed module profiles, including their packages. In case no profile was provided, all installed profiles get removed.

I have one more question.
How to remove a RPM that is not included in any profile of a module?
Every RPM in a module should be included in a profile of the module?

For example, "ruby-doc", "rubygem-pg" and "rubygem-pg-doc" are not included in any profile of modules/ruby:2.6 .

We can see all the RPM in ruby:2.6 like this.

```
$ dnf module info ruby:2.6
...
Artifacts    : ruby-0:2.6.3-120.module_f30+4422+f50e013d.i686
...
             : ruby-doc-0:2.6.3-120.module_f30+4422+f50e013d.noarch
...
             : rubygem-pg-0:1.1.4-3.module_f30+4422+f50e013d.src
             : rubygem-pg-0:1.1.4-3.module_f30+4422+f50e013d.x86_64
...
             : rubygem-pg-doc-0:1.1.4-3.module_f30+4422+f50e013d.noarch
```

Below is the right way to install and remove the RPMs that are not included in any profile of a module?

```
$ sudo dnf module enable ruby:2.6
$ sudo dnf install ruby-doc rubygem-pg rubygem-pg-doc

$ rpm -q ruby-doc rubygem-pg rubygem-pg-doc
ruby-doc-2.6.3-120.module_f30+4422+f50e013d.noarch
rubygem-pg-1.1.4-3.module_f30+4422+f50e013d.x86_64
rubygem-pg-doc-1.1.4-3.module_f30+4422+f50e013d.noarch

$ sudo dnf remove ruby-doc rubygem-pg rubygem-pg-doc
$ rpm -q ruby-doc rubygem-pg rubygem-pg-doc
package ruby-doc is not installed
package rubygem-pg is not installed
package rubygem-pg-doc is not installed
```

Comment 2 Jaroslav Mracek 2019-07-22 17:52:00 UTC
I tried to reproduce your issue but without a success. See:

I had no ruby package on my system and a run: "sudo dnf module install ruby:2.6/default". It installed ruby package and 10 others as a dependencies.
Then command "dnf module remove ruby" removed 11 packages included ruby package. 

But what you experienced could be due.

1. ruby package was installed before "sudo dnf module install ruby:2.6/default".
  Dnf remember the reason why package appears on the system. The reason could be changed by "dnf mark group ruby"
 command
2. "dnf module remove ruby" cannot remove ruby package because other user installed package depends on it
  This is a protection to system

So far I don't see the behaviour as a bug.

To your questions:
Yes you can install any package from the module on your system and also remove it.

Comment 3 Jaroslav Mracek 2019-07-23 07:11:56 UTC
I create a patch that enhance the documentation of dnf module remove command - https://github.com/rpm-software-management/dnf/pull/1436.

Comment 4 Jun Aruga 2019-07-23 07:57:40 UTC
Jaroslav, many thanks for checking and sending the patch.

> I tried to reproduce your issue but without a success. See:

Let me see. I try to reproduce considering your situation.

Comment 5 Jun Aruga 2019-07-23 10:12:39 UTC
I checked my environment. You are right. The issue happens when ruby and ruby-devel RPM packages are installed before running "dnf module install ruby:2.6/default".

Initial condition.

Ruby module is not enabled.

```
$ dnf module list ruby
...
Fedora Modular 30 - x86_64 - Updates
Name       Stream      Profiles      Summary                                                  
ruby       master      default       An interpreter of object-oriented scripting language     
ruby       2.5         default       An interpreter of object-oriented scripting language     
ruby       2.6         default       An interpreter of object-oriented scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

$ rpm -q ruby
package ruby is not installed
```

Install ruby and ruby-devel RPMs without Ruby module.

```
$ sudo dnf install ruby
...
Installed:
  ruby-2.6.3-120.fc30.x86_64                     rubygem-bigdecimal-1.4.1-120.fc30.x86_64    
  rubygem-did_you_mean-1.3.0-120.fc30.noarch     rubygem-io-console-0.4.7-120.fc30.x86_64    
  rubygem-openssl-2.1.2-120.fc30.x86_64          rubygem-rdoc-6.1.0-120.fc30.noarch          
  rubygems-3.0.3-120.fc30.noarch                 ruby-libs-2.6.3-120.fc30.x86_64             
  rubygem-irb-1.0.0-120.fc30.noarch              rubygem-psych-3.1.0-120.fc30.x86_64         
  rubygem-json-2.2.0-200.fc30.x86_64             rubypick-1.1.1-10.fc30.noarch               

Complete!

$ sudo dnf install ruby-devel
...
Installed:
  ruby-devel-2.6.3-120.fc30.x86_64                                                            

Complete!
```

Then install Ruby 2.6 module.
Only ruby, ruby-devel and ruby-libs are updated.
This was already unintended situation.

```
$ sudo dnf module install ruby:2.6/default
...
Upgrading:
 ruby           x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular      42 k
 ruby-devel     x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular     199 k
 ruby-libs      x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular     2.9 M
Installing module profiles:
 ruby/default                                                                                
Enabling module streams:
 ruby                      2.6      
...
Total download size: 3.1 M
Is this ok [y/N]: y
...
Upgraded:
  ruby-2.6.3-120.module_f30+4422+f50e013d.x86_64                                              
  ruby-devel-2.6.3-120.module_f30+4422+f50e013d.x86_64                                        
  ruby-libs-2.6.3-120.module_f30+4422+f50e013d.x86_64                                         

Complete!
```

Here is what I reported.

```
$ sudo dnf module remove ruby:2.6/default
Last metadata expiration check: 0:04:44 ago on Tue 23 Jul 2019 11:43:03 AM CEST.
Dependencies resolved.
==============================================================================================
 Package               Architecture         Version               Repository             Size
==============================================================================================
Disabling module profiles:
 ruby/default                                                                                

Transaction Summary
==============================================================================================

Is this ok [y/N]: y
Complete!
```


```
$ dnf module list ruby
...
Name      Stream       Profiles      Summary                                                  
ruby      master       default       An interpreter of object-oriented scripting language     
ruby      2.5          default       An interpreter of object-oriented scripting language     
ruby      2.6 [e]      default       An interpreter of object-oriented scripting language     

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
```

I tried to remove ruby module with "--allowerasing" option.
Because I wanted to remove RPMs in Ruby module that other package depends on.

I do not understand "Unable to match profile in argument ruby:2.6/default" message.
What it means?

```
$ sudo dnf --allowerasing module remove ruby:2.6/default
Last metadata expiration check: 0:06:46 ago on Tue 23 Jul 2019 11:43:03 AM CEST.
Unable to match profile in argument ruby:2.6/default
Dependencies resolved.
Nothing to do.
Complete!

$ sudo dnf module remove ruby:2.6/default
Last metadata expiration check: 0:07:40 ago on Tue 23 Jul 2019 11:43:03 AM CEST.
Unable to match profile in argument ruby:2.6/default
Dependencies resolved.
Nothing to do.
Complete!
```

Comment 6 Jun Aruga 2019-07-23 11:46:12 UTC
https://docs.fedoraproject.org/en-US/modularity/using-modules/#_installing_modules

I want "dnf module something" command which do "install ruby package and 10 others as a dependencies" like new installation even some RPMs (ruby, ruby-devel, and etc) in the profile are already install.

Current result of "sudo dnf --allowerasing module install ruby:2.6/default" is not like that.

```
$ rpm -q ruby ruby-devel
ruby-2.6.3-120.fc30.x86_64
ruby-devel-2.6.3-120.fc30.x86_64

$ sudo dnf module reset ruby

$ sudo dnf --allowerasing module install ruby:2.6/default
Last metadata expiration check: 0:00:14 ago on Tue 23 Jul 2019 01:41:09 PM CEST.
Dependencies resolved.
==============================================================================================
 Package        Arch       Version                                  Repository           Size
==============================================================================================
Upgrading:
 ruby           x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular      42 k
 ruby-devel     x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular     199 k
 ruby-libs      x86_64     2.6.3-120.module_f30+4422+f50e013d       updates-modular     2.9 M
Installing module profiles:
 ruby/default--------------------------------------------------------------------------------
Enabling module streams:
 ruby                      2.6---------------------------------------------------------------

Transaction Summary
==============================================================================================
Upgrade  3 Packages

Total download size: 3.1 M
Is this ok [y/N]:-
```

Comment 7 Jaroslav Mracek 2019-07-23 16:07:38 UTC
DNF remembers a reason how package appears on the system in first plase. The strongest is user, then group, then dependency.

Ok, Lets go with your example:
no ruby on the system.

sudo dnf install ruby
# installs ruby with reason user, other packages have a reason dependency
# user installed packages are not removed by "dnf module remove" command

sudo dnf module install ruby:2.6/default
# installs module profile called "default" that consist only ruby package
# It upgrades ruby package to modular version, but it keeps reason user, because reason is inherited.
# Profile 'default' is marked as installed

sudo dnf module remove ruby:2.6/default
# remove profile named default
# it also tries to remove ruby package because it is described in profile, but it cannot because ruby package is user installed. Only group installed packages can be removed.

To provide functionality like you expect you can:
1:
no ruby package on the system
sudo dnf install ruby
sudo dnf module install ruby:2.6/default
sudo dnf mark group ruby # it will change reason of ruby package to group
sudo dnf module remove ruby:2.6/default  # ruby package will go away

or 2:
no ruby package on the system
sudo dnf module install ruby:2.6/default  # it will installs ruby package with group reason
sudo dnf module remove ruby:2.6/default  # ruby package will go away

Comment 8 Jun Aruga 2019-07-24 16:32:32 UTC
Thanks for very detailed explanation. I understand the behavior now.

Is it possible to update below Fedora modurarity's document as a NOTE?

https://docs.fedoraproject.org/en-US/modularity/using-modules/#_installing_modules

It might be after below PR will be merged, as it modifies the page.
https://pagure.io/fedora-docs/modularity/pull-request/64

Comment 9 Adam Samalik 2019-08-14 13:40:34 UTC
Jun: I'll get it into the docs and post a link back here.

Comment 10 Jun Aruga 2019-08-14 13:46:17 UTC
Adam, sure. b

Comment 11 Fedora Update System 2019-10-02 08:31:51 UTC
FEDORA-2019-049b4836a6 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-049b4836a6

Comment 12 Fedora Update System 2019-10-03 01:52:30 UTC
dnf-4.2.11-2.fc30, dnf-plugins-core-4.0.10-1.fc30, libdnf-0.35.5-2.fc30, librepo-1.10.6-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-049b4836a6

Comment 13 Adam Samalik 2019-10-03 11:22:33 UTC
I've just documented that.

It will appear in about an hour after this comment on this URL: https://docs.fedoraproject.org/en-US/modularity/removing-modules/

Commit: https://pagure.io/fedora-docs/modularity/c/30a3aad48f901fa948e0db63b635a3db25e3ca13?branch=master

Comment 14 Jun Aruga 2019-10-03 13:03:39 UTC
Thanks for improving dnf, and the updated document! The document looks good to me!

> https://bodhi.fedoraproject.org/updates/FEDORA-2019-049b4836a6

What behavior is "dnf" changed about this ticket?
Which item in the bodhi release note is related to this ticket?

Comment 15 Fedora Update System 2019-10-10 16:55:55 UTC
dnf-4.2.11-2.fc30, dnf-plugins-core-4.0.10-1.fc30, libdnf-0.35.5-2.fc30, librepo-1.10.6-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.