You are not logged in.

#1 2021-04-07 13:38:03

cooperbang
Member
Registered: 2021-04-07
Posts: 3

pacman Sync vs. Refresh

Hi,

would somebody tell me the difference between sync (-S) and sync refresh (-Sy)?
What´s the difference between pacman -S and pacman -Sy?

Is syncing not the same as refreshing?

Offline

#2 2021-04-07 13:50:40

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 12,520

Re: pacman Sync vs. Refresh

You will notice that an -S without a target package to install is not doing anything, so they are immediately different by that alone.

Assuming you are passing a target package -S will (try) to install whatever package version is currently present according to your database. If you do that on a system where the DB is out of date you'll likely get a 404.

The refresh is explicitly for updating your database and is the precondition for pacman to know which packages currently on your system need updating. You basically have two databases, the list of packages you've installed on your system and the list of packages theoretically possible for installation according to your sync database. If these differ you'll get offered an upgrade with the -u flag

You should almost never run -Sy package without an -u as that could constitute a partial update.

Online

#3 2021-04-07 14:29:25

cooperbang
Member
Registered: 2021-04-07
Posts: 3

Re: pacman Sync vs. Refresh

Ok, thanks for the answer, but I still don´t understand completely...

More precisely: What´s the difference between pacman -Su and pacman -Syu?

Why sometimes there is the "y" and sometimes not?

Offline

#4 2021-04-07 14:31:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,181

Re: pacman Sync vs. Refresh

The difference is `pacman -S <package>` is a valid command that will either succeed in installing the package, or fail gracefully if it is no longer available (in which case you should use `pacman -Syu <package>).  In contrast neither `pacman -Sy` nor `pacman -Sy <package>` should ever be used.  They will cause problems.  Add a 'u' to either one of those, though, and you'd be fine.

EDIT: to address your follow-up: `pacman -Su` is harmless, but pointless.  There should never be a need for that command.  The only valid use for it is if you just ran `pacman -Sy` (which you should never do) then `pacman -Su` would leave you in a safe state (of course just running `pacman -Syu` at that time would have the same result).

The reason -Su is (or should be) pointless, is that it will only update packages to the versions already in your local copy of the databases.  You should, however, never be in a position where your installed packages do not match the versions in your local copy of the sync databases.  So unless you already did something wrong, `pacman -Su` will always simply reply that there is nothing to do.
`pacman -Syu` will first download the newest sync databases, then upgrade all packages to the version specified in the new databases.

Last edited by Trilby (2021-04-07 14:36:47)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2021-04-07 14:38:45

cooperbang
Member
Registered: 2021-04-07
Posts: 3

Re: pacman Sync vs. Refresh

ok, thanks:

I was confused because I found the -Su version here https://archlinux.org/pacman/pacman.8.html:

"You can also use pacman -Su to upgrade all packages that are out-of-date. See Sync Options below.
When upgrading, pacman performs version comparison to determine which packages need upgrading."

Edit: So, is it correct that -u never should be used without -y and -y never without -u?

I think pacman should display a warning message if someone uses pacman -Sy or -Su ...

Last edited by cooperbang (2021-04-07 14:54:52)

Offline

#6 2021-04-07 15:18:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 25,181

Re: pacman Sync vs. Refresh

Good manual pages tend to be exhaustive in covering every possible invocation - that's not the same as recommending it as normal use.

cooperbang wrote:

is it correct that -u never should be used without -y and -y never without -u?

I'd only say the latter.  Never use '-Sy' without 'u'.  Never ever ever ... except for those times you should - but these are very rare and very specific circumstances that will never actually apply to most users, and if they are going to apply to you, you'd know exactly why and what you are doing.  So for all intents and purposes, "never".

Using '-Su' without '-y' is fine.  It's not useful, and I see no purpose in it, but it will cause no harm.  Again, it is one viable solution if you foolishly just ran an '-Sy', follow it with a '-Su' or an '-Syu'.

cooperbang wrote:

I think pacman should display a warning message if someone uses pacman -Sy or -Su ...

I'd actually agree to a warning for '-Sy', and I think I've suggested as much previously on the forums (though not on a bug tracker or anywhere where it'd get the attention of the relevant devs.)  It should be a warning though as there are those exceedingly rare circumstances where that's what one actually wants to do.

In reality this shouldn't be a response to specific flags, as there are other ways to get the same result: run `pacman -Syu` then interrupt it with Ctrl-C, there are likely other ways too.  I think there should be a check perhaps either at startup or closing of pacman (or both) to give a notice / warning if the currently installed packages are out of sync with the local copy of the databases and prompting the user to run a full upgrade.

To be sure I'm not overstating the case, running `pacman -Sy` will not actually result in any immediate problems.  But it serves no useful purpose, and creates a situation where future common pacman transactions will result in significant problems.  So -Sy leaves the system not "broken" but extremely fragile - and it should not be left in such a state.

Last edited by Trilby (2021-04-07 15:24:06)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB