Bug 1110780 - dnf swap not supported
dnf swap not supported
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
25
All Linux
low Severity unspecified
: ---
: ---
Assigned To: Jaroslav Mracek
Fedora Extras Quality Assurance
: Reopened, Triaged
: 1128358 1149014 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-18 08:40 EDT by Heiko Adams
Modified: 2017-02-10 11:04 EST (History)
18 users (show)

See Also:
Fixed In Version: dnf-0.6.3-2.fc21
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-02-10 11:04:30 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Heiko Adams 2014-06-18 08:40:18 EDT
yum has a very usefull swap command which allowes replacing a package by another package with one single command. This command is currently not supported by yum.
Comment 1 Radek Holy 2014-06-18 11:04:35 EDT
Hello, thank you for the report. See this blog post: http://dnf.baseurl.org/2014/06/06/vote-for-yum-features-that-you-miss-in-dnf/

Please also note that there is an '--allowerasing' switch (see http://dnf.readthedocs.org/en/latest/cli_vs_yum.html#packages-replacement-without-yum-shell). The more (real) (detailed) use cases not covered by this switch you provide the better for you.
Comment 2 Heiko Adams 2014-06-18 14:47:35 EDT
No, I'm afraid you missunderstood me. The swap command allows to remove a package and install another package in one transaction. You could say its a shortcut for
  yum remove x && yum install y
Comment 3 Radek Holy 2014-06-19 02:37:13 EDT
Oh, yes, sure, sorry. OK, we'll see.

I kind of don't like that you can just remove something and install something in one transaction. What about other operations? But then it would be more like 'yum shell' (but in the form like 'python -c "cmd1;cmd2"'). So personally I don't like this command as I can't see the reason/use-case why this pair of operations has the privilege to be a standalone command. But that's just my opinion.
Comment 4 Jan Zeleny 2014-06-19 03:27:39 EDT
There are some situations where this is used. Most recently this command has been used to switch between fake and real systemd in Docker base images. However I was assured by Ales that the same thing is doable by dnf as it is, even though it's not called swap.

Heiko, could you please specify concrete reproducible situation where the --allowerasing switch doesn't work as you would expect? That's what the team needs to see. The point is not to implement something we thing users want but rather to address concrete problems. I'm afraid this will eventually get closed if there is no concrete and reproducible use case. Thanks
Comment 5 Radek Holy 2014-06-19 03:31:28 EDT
The swap command can be used also for two non-conflicting packages. That's the point I missed too.
Comment 6 Jan Zeleny 2014-08-11 06:59:06 EDT
*** Bug 1128358 has been marked as a duplicate of this bug. ***
Comment 7 Ales Kozumplik 2014-08-11 07:39:29 EDT
Putting into needinfo per comment 4.
Comment 8 Ales Kozumplik 2014-08-14 03:16:09 EDT
Possibly a dupe of bug 963137.
Comment 9 Vít Ondruch 2014-08-29 19:16:36 EDT
I am afraid that without this functionality, there is not possible to replace YUM by dnf-yum package:

$ sudo dnf install dnf-yum
Chyba: package dnf-yum-0.6.1-1.fc22.noarch conflicts with yum provided by yum-3.4.3-153.fc22.noarch


There is neither not supported "dnf shell", which would probably allow that.
Comment 10 Vít Ondruch 2014-08-29 19:19:34 EDT
Actually, the --allowerasing could probably achieve that, but it seems that prior that, mock and other packages should replace dependency on yum package by dependency on yum executable (if that is enough).
Comment 11 Heiko Adams 2014-09-02 16:22:21 EDT
Jan, the last situation I can remember I used yum's swap command was replacing hexachat by polari. 

Or in general: the swap command is useful if you want to replace a package with another package providing a similar function but with no dependencies to package to be replaced.
Comment 12 Ales Kozumplik 2014-09-19 05:33:35 EDT
I still don't see it:

If we want to swap package A for package B where the two don't conflict:

dnf install B && dnf erase A

That's what I believe exactly matches case described in comment 11.

If we want to swap package A for package B where B conflicts with A:

dnf --allowerasing install B

Reporter, can you provide a valid case, preferably with solver debug data [1], where one of the above operations don't suffice? Thanks!

[1] http://dnf.baseurl.org/2013/11/25/reporting-depsolving-bugs/
Comment 13 Honza Horak 2014-09-24 04:06:44 EDT
(In reply to Ales Kozumplik from comment #12)
> If we want to swap package A for package B where B conflicts with A:
> 
> dnf --allowerasing install B

Well, this works for my use case, thanks. Would it be possible to add a comment into dnf(8) man page that `swap`-like action is able to be done this way?
Comment 14 Rahul Sundaram 2014-10-02 01:36:58 EDT
It might be better to have swap be an alias for --allow-erasing for compatibility.
Comment 15 Tim Lauridsen 2014-10-02 03:50:56 EDT
(In reply to Rahul Sundaram from comment #14)
> It might be better to have swap be an alias for --allow-erasing for
> compatibility.

Dont do the same thing, --allow-erasing tells the solver it must remove installed packages to solve issues. So it is a more general purpose than just replaceing 1 package with another with the same provides.

yum swap is a shotcut for

yum shell
remove x 
install y
run
Comment 16 Rahul Sundaram 2014-10-02 03:55:10 EDT
I know it doesn't do the same thing.  To avoid confusion, the end result I am looking for is that dnf swap foo bar actually be made to work preserving command line compatibility.
Comment 17 Honza Silhan 2014-10-03 11:45:44 EDT
*** Bug 1149014 has been marked as a duplicate of this bug. ***
Comment 18 Honza Horak 2014-10-14 11:50:33 EDT
Another idea how to make things a bit better would be changing the help/man of dnf so it gives a clue to users searching for swap (include this word in the description), e.g.:

        --allowerasing
              Allow erasing of installed packages to resolve dependencies.
              In order to swap two packages run dnf install with --allowerasing.
Comment 19 Honza Silhan 2014-10-16 08:52:16 EDT
I can mention it in man and cli vs yum differences and manual.
Comment 20 Rahul Sundaram 2014-10-16 09:27:23 EDT
Is there any strong reasons NOT to support it in dnf?  It is widely used in yum in many scripts as well and having to change it all again to support dnf is a hassle.
Comment 21 Radek Holy 2014-10-16 09:33:45 EDT
Rahul, we don't need/want two commands for the same use case.
Comment 22 Rahul Sundaram 2014-10-16 09:49:29 EDT
Well, that is a bit of circular logic.  You added something new and want to break compatibility with an existing command because you added something new.
Comment 23 Radek Holy 2014-10-16 10:08:06 EDT
The switch was introduced (as you might remember the bug 963137) with the hope that we can get rid of the "shell" command. Since the switch is already supported and it supports your use case, we don't need to add yet another command.
Comment 24 Rahul Sundaram 2014-10-16 10:11:20 EDT
Before the new switch was introduced, I noted in that bug report that yum already supports a swap command and it would have been better to support it instead of introducing a new command.  This is what I am reiterating here.
Comment 25 Rahul Sundaram 2014-10-16 10:25:10 EDT
To expand on that,  it doesn't particularly matter whether a new switch is being introduced to handle more use cases but yum swap is widely used.  This is not some edge corner case or undocumented option.  

https://www.google.com/search?q=yum+swap&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb

It is also not merely command line users but also configuration management systems and scripts that need to be changed.  For example, I am working on a patch to support dnf in a newly introduced script which uses yum swap and I have to add special conditions just because dnf doesn't support the same option. 

https://github.com/fedora-cloud/cloudtoserver/issues/4

Docker files use yum swap on a regular basis.  We have it being used in our Fedora wiki itself in many places.  Please don't break compatibility without very strong reasons to do so.
Comment 26 Tim Lauridsen 2014-10-16 12:47:59 EDT
(In reply to Rahul Sundaram from comment #25)
> To expand on that,  it doesn't particularly matter whether a new switch is
> being introduced to handle more use cases but yum swap is widely used.  This
> is not some edge corner case or undocumented option.  

yum shell is also used a lot of places, but dnf dont support that
dnf != yum, one of idea by dnf was to clean things up and have more maintainable code base, all features is build about strong and sane usecases, an it was there in yum is not a strong usecase.
as the dnf developers already said, they dont add an extra cmd, when the feature to swap 2 packages allready exist.

Fedora is changing a lot of stuff all the time, so we have to learn new ways all the time.
Comment 27 Rahul Sundaram 2014-10-16 13:28:26 EDT
Thank you bringing up yum shell.  That is a good example to compare and contrast.  yum shell is not used in scripts or configuration management or anywhere else other than interactively and is also a much more complex feature.

dnf may not be yum but calls itself yum4 in 

https://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF
 
Every change in the command line of a heavily used tool like yum or any successor to it adds a *substantial* burden to users and administrators.  I have already highlighted the very important "use case".  It is called compatibility.
Comment 28 Tim Lauridsen 2014-10-17 03:27:22 EDT
From: https://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF

For anybody using the command line directly there will be some differences, but all the important operations are available with DNF, using the same CLI syntax.

there can of course different views on what important operations are

Fedora has a long history of introducing new stuff there is not compatibility
with the old ones.

Ex. python2 -> python3, udisks -> udisk2, rules in PolycyKit (ini files to JS) etc.

If you are looking at the dnf python api it is totally different from yum, but dnf has a well documented public api, an yum has no api docs at all. All api consumers will have to rewrite there code, in this view the change from
using 'yum swap' to 'dnf install --allowerasing' seems like minor thing.

I have never used 'yum swap' and I dont see myself as a novice yum user, so I think that normal user dont use it very often or even know it exists.
Comment 29 Rahul Sundaram 2014-10-17 05:55:16 EDT
You are setting up straw man arguments.  I never said Fedora cannot change.  I am saying, don't break compatibility in the command line without a strong justification for doing so.

As far the claim that yum swap is not popular, I welcome you to look at google search results and Fedora wiki.
Comment 30 Heiko Adams 2014-10-20 15:58:39 EDT
Sorry, but I don't see any advantage in now doing 2 command line calls for a job yum does with 1 command line call.

So if you think you don't need/want a swap command, its okay to me because ATM I'm using Xfce which currently doesn't depend on dnf or hawkeye and which allows me to continue using yum.
Comment 31 Tim Lauridsen 2014-10-21 00:54:52 EDT
(In reply to Heiko Adams from comment #30)
> Sorry, but I don't see any advantage in now doing 2 command line calls for a
> job yum does with 1 command line call.
> 

'dnf --allowerasing install foobar' is only one command
Comment 32 Honza Silhan 2014-11-04 08:11:41 EST
Reference of swap command from yum mentioned in "cli vs yum" and in dnf man page.
Comment 33 Fedora Update System 2014-12-09 09:06:47 EST
dnf-0.6.3-2.fc21,dnf-plugins-core-0.1.4-1.fc21,hawkey-0.5.2-1.fc21 has been submitted as an update for Fedora 21.
https://admin.fedoraproject.org/updates/dnf-0.6.3-2.fc21,dnf-plugins-core-0.1.4-1.fc21,hawkey-0.5.2-1.fc21
Comment 34 Fedora Update System 2014-12-11 23:32:53 EST
Package dnf-0.6.3-2.fc21, hawkey-0.5.2-1.fc21, dnf-plugins-core-0.1.4-1.fc21:
* should fix your issue,
* was pushed to the Fedora 21 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.6.3-2.fc21 hawkey-0.5.2-1.fc21 dnf-plugins-core-0.1.4-1.fc21'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-16760/dnf-0.6.3-2.fc21,dnf-plugins-core-0.1.4-1.fc21,hawkey-0.5.2-1.fc21
then log in and leave karma (feedback).
Comment 35 Fedora Update System 2014-12-13 04:53:55 EST
dnf-0.6.3-2.fc21, hawkey-0.5.2-1.fc21, dnf-plugins-core-0.1.4-1.fc21 has been pushed to the Fedora 21 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 36 Ali Akcaagac 2015-04-08 04:53:55 EDT
I was just pointed at this *closed* bugreport from a maintainer ? developer ? ... Not really sure what his intentions was by doing so but reading through some comments here I am willing to back up the reasons brought up by Heiko Adams.

https://bugzilla.redhat.com/show_bug.cgi?id=963137#c17
Comment 37 Matthew Miller 2016-03-22 08:15:25 EDT
Is there any reason to _not_ support dnf swap / yum swap with DNF?

See http://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/mess
age/5VBZ45TRTWNB7NAXW5HPYKZIUFMAW6HZ/ for a case where the --allowerasing workaround does not help.

Additionally

a) "install --allowerasing" is not particularly easy to find or even remember; I can't really think of anyone finding it any way _other_ than finding in the FAQ for "how do I do `yum swap` with dnf?", or reading a "secrets of DNF" article.

b) It worked fine in yum; why change the interface?
Comment 38 Kamil Dudka 2016-03-22 08:58:23 EDT
Could --allowerasing be extended to accept an operand?

Something like a wildcard and/or a list of packages allowed to be erased would work for me.  Allowing dnf to erase everything may result in unexpected decision to be made by dnf.

For inspiration, you can have a look at the option --remove-if-dependent which is offered by Paludis:

http://paludis.exherbo.org/clients/cave-resolve.html

Some other options (such as --permit-downgrade, --permit-old-version, --purge, or --uninstalls-may-break) may be also worth adding to dnf, but that is another story :-)

Otherwise, it is IMO good that it is implemented as a switch (instead of dnf command) because the switch could also be used for other commands than install.
Comment 39 Honza Silhan 2016-03-23 05:57:37 EDT
(In reply to Matthew Miller from comment #37)
> Is there any reason to _not_ support dnf swap / yum swap with DNF?
> 
> See
> http://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/
> mess
> age/5VBZ45TRTWNB7NAXW5HPYKZIUFMAW6HZ/ for a case where the --allowerasing
> workaround does not help.

Proper way to upgrade to new Fedora version is by using system-upgrade or distro-sync alternatively. In this case excluding (-x) broken packages is the easiest option.

> Additionally
> 
> a) "install --allowerasing" is not particularly easy to find or even
> remember; I can't really think of anyone finding it any way _other_ than
> finding in the FAQ for "how do I do `yum swap` with dnf?", or reading a
> "secrets of DNF" article.

In case there are some conflicts, DNF shows a hint about `--allowerasing` usage.

> b) It worked fine in yum; why change the interface?

Maybe we can support it in yum compatible layer or DNF itself.

(In reply to Kamil Dudka from comment #38)
> Could --allowerasing be extended to accept an operand?
> 
> Something like a wildcard and/or a list of packages allowed to be erased
> would work for me.  Allowing dnf to erase everything may result in
> unexpected decision to be made by dnf.

That's a good idea, Kamil. Libsolv already supports specifying concrete packages for removal. Protected packages should use this interface too to exclude protected packages from transaction removal beforehand not report just error afterwards.

> Some other options (such as --permit-downgrade, --permit-old-version,
> --purge, or --uninstalls-may-break) may be also worth adding to dnf, but
> that is another story :-)

downgrade is permitted when --allowerasing is set.
Comment 40 Jan Kurik 2016-07-26 00:28:12 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.
Comment 41 Pavel Raiskup 2016-12-15 18:19:40 EST
I know this is result of several poor packaging issues, but I faced this
recently and solved with `yum-deprecated shell` only..  even the `yum swap`
was not enough because I needed to swap two pairs of packages.

The issue (for the story, consider I've done this on production server,
but I still plan doing this in production):
I planned to switch from package 'foo-modified' to package 'foo', where
the package foo-modified is really  _poorly_ downstream-modified version
of 'foo' (no Obsoletes nor Collides tags), that means -> only *implicit*
file collisions between those two packages.  The 'foo-modified' is not
needed because Fedora's default 'foo' is already suitable for me, yay!

Steps I tried:
The `dnf install --allowerasing foo` calculated transaction (no issue
reported) and once I hit the 'Y' button, the execution of transaction
failed reporting file collisions (on RPM level).

Is there a way to replace *non-explicitly* colliding packages in dnf in
one transaction?  The --allowerasing doesn't help because there's nothing
obvious in the install transaction which _would make dnf think_ the
removal of `foo-modified` is needed.

I don't want to `dnf remove foo-modified && dnf install foo` because
remove might succeed and install *could* fail -> and that would cause
additional downtime... because system might be in inconsistent state (even
after re-installation of foo-modified).
Comment 42 Pavel Raiskup 2016-12-15 18:24:54 EST
(In reply to Pavel Raiskup from comment #41)
> (no Obsoletes nor Collides tags)

Sorry, s/Collides/Conflicts/.
Comment 43 Pavel Raiskup 2016-12-15 18:54:40 EST
Example:

    $ sudo dnf -y copr enable praiskup/bug-1110780-dnf-swap
    $ sudo dnf -y install foo-modified
    ...
    Complete!
    $ sudo dnf -y --allowerasing foo
    ...
    file /collides_here from install of foo-20161216_0044-0.fc25.x86_64 conflicts with file from package foo-modified-20161216_0044-0.fc25.x86_64
    ...

HOWTO 's/foo-modified/foo/' with dnf then?  This works (for now):

    $ sudo yum-deprecated -y swap foo-modified foo
    ...
    Complete!
Comment 44 Jaroslav Mracek 2016-12-16 10:36:41 EST
Here is pull-request that add support of swap command: https://github.com/rpm-software-management/dnf/pull/679
Comment 45 Pavel Raiskup 2016-12-19 00:27:41 EST
Thanks for working on it.  FWIW, `dnf swap` is not enough, I actually
needed to have two `dnf swap` calls in once transaction (so I used `yum
shell` to resolve my issues).  Let me know if you want me to prepare
example (or if this deserves new ticket).
Comment 46 Michal Luscon 2016-12-19 04:31:45 EST
Hi Pavel,

DNF shell is also on the way - https://github.com/rpm-software-management/dnf/pull/658 .
Comment 48 Jaroslav Mracek 2017-02-10 11:04:30 EST
Bug fixed in version of dnf-2.0.1-1.

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