# synth "rebuild repository" question



## rwv37 (Feb 2, 2021)

Towards the end of doing a `synth build`, synth asks you something like "Would you like to rebuild the repository?" Is saying yes to this supposed to accomplish the same thing as the separate `synth rebuild-repository` command would do?

If it is supposed to, then I think there's something wrong with it. I've been using synth for months and months at least, maybe a year or even more. Every time it asks me if I want to rebuild the repository, I answer yes. But then after the `synth build` completes, I've occasionally run into problems where `pkg upgrade -r Synth` doesn't upgrade some of the packages that it seemingly should. Eventually I figured out that doing a `synth rebuild-repository` after the `synth build` but before the `pkg upgrade -r Synth` causes synth to remove a bunch of old packages (despite the fact that I had already answered yes when asked if I wanted to rebuild the repository), and then the `pkg upgrade -r Synth` works as expected. I have never once had the issue after figuring this out (which was many, many `synth build`s ago).

On the other hand, if it's not supposed to, then what _is_ it supposed to do? How is it supposed to differ than `synth rebuild-repository`, and what is its intended purpose?


----------



## SirDice (Feb 2, 2021)

rwv37 said:


> Towards the end of doing a `synth build`, synth asks you something like "Would you like to rebuild the repository?" Is saying yes to this supposed to accomplish the same thing as the separate `synth rebuild-repository` command would do?


Yes. Don't use Synth but I can read the synth(8) manual page.


```
synth build [file | port-origin ...]
     The build command differs from the	just-build command by asking the user
     if	they wish to rebuild the local repository when the building is com-
     plete. The	answer is usually "N" (for "no") because rebuilding the	repos-
     itory can take a few minutes to complete, and it only makes sense to do
     when all the building is complete.	Should the user	opt to rebuild the
     repository, synth will then ask if	the user wishes	to install the pack-
     ages that come from the ports list	on the system.
```


```
synth rebuild-repository
     The rebuild-repository command will perform a full	sanity check on	all
     packages present in the packages directory	and remove the ones which fail
     the check.	 The local Synth repository will be created (or	recreated) us-
     ing the remaining packages.  This step is also done as part of several
     other commands, so	it mainly exists for scripting purposes.
```


----------



## rwv37 (Feb 2, 2021)

Yeah, thanks for the snark.

I've read both of those previously. They do not answer my question, as far as I can tell.


----------



## unitrunker (Feb 2, 2021)

Look at one of the packages that synth removed. Was it deprecated or removed from ports? Individual ports come and go over time.


----------



## rwv37 (Feb 2, 2021)

unitrunker, thanks, but no, neither (unless by "deprecated" you don't mean anything more than simply "has a newer version available"). It happens very frequently, to a lot of packages, and it is always ones that synth itself just rebuilt to a newer version when I did the `synth build`. Like:

(1) `pkg version -v` reports that a bunch of ports have updates available, including some/awesomeport, of which version 4.48.21 is installed, but having 4.48.22 available.

(2) `synth status {my-top-level-packages}` reports that running `synth build {my-top-level-packages}` would build a bunch of stuff, including building version 4.48.22 of some/awesomeport.

(3) `synth build {my-top-level-packages}` then does in fact build a bunch of stuff, including version 4.48.22 of some/awesomeport.

(4) Towards the end of the `synth build`, synth asks me if I want to rebuild the repository. I answer "yes".

(5a) After `synth build` is complete, nowadays I would run `synth rebuild-repository`, and everything would work fine thereafter. But...

(5b) Before I had figured out that apparently saying "yes, rebuild the repository" as in step 4 is apparently not the same as saying "rebuild the repository" as in step 5a, I had been simply not doing step 5a at all, leading to:

(6) `pkg upgrade -r Synth` installs a bunch of things that synth just built, but does _not_ install version 4.48.22 of some/awesomeport. Instead, it just leaves 4.48.21 installed on my system. Remember, synth _did_ build version 4.48.22.

On the other hand, if I _had_ done a `synth rebuild-repository` in step 5b, synth would have reported that it was removing 4.48.21 from the repository. And the `pkg upgrade -r Synth` in step 6 would thereafter install 4.48.22 into my system.

After I figured this out, I poked around a little more to try to figure out what the actual difference was, and it's this:

(A) After `synth build` completes (and, remember, synth has built the new version of awesomeport), the directory /var/synth/live_packages/All contains not just awesomeport-4.48.22.tmz, but also awesomeport-4.48.21.tmz. This is true despite having answered "yes" when synth asked if I wanted it to rebuild the repository.

(B) If you then go straight to `pkg upgrade -r Synth`, pkg does not upgrade your system with version 4.48.22, and instead just leaves 4.48.21 installed.

(C) But if you instead do a `synth rebuild-repository` first, synth deletes /var/synth/live_packages/All/awesomeport-4.48.21.tmz, leaving only awesomeport-4.48.22.tmz. Doing a `pkg upgrade -r Synth` will then cause pkg to install version 4.48.22.

So, the question is essentially: Is this the way it's supposed to be? Answering "yes" to "would you like to rebuild the repository" is _not_ supposed to remove /var/synth/live_packages/All/awesomeport-4.48.21.tmz, even though `synth rebuild-repository` _is_ supposed to remove it?

I have been assuming that no, it's not supposed to be that way, in which case it seems like there's a bug in synth (i.e. answering "yes" should, but does not, cause that file to be removed), or a bug in pkg (i.e. `pkg upgrade -r Synth` should just ignore awesomeport-4.48.21.tmz since awesomeport-4.48.22.tmz also exists), or maybe something like a pkg option that I'm unaware of (e.g. I really should be doing `pkg upgrade -r Synth --behave-like-bob-expects`).

But on the other hand, if this _is_ the way it's supposed to be, then what is the purpose of saying "yes" when synth asks if you want to rebuild the repository? I understand that in some sense the answer is "that will make it rebuild the repository", but if you then also need to later do a `synth rebuild-repository` in order for the whole process to work, then what's the point of bothering with telling it "yes, I would like to rebuild the repository"?


----------



## unitrunker (Feb 2, 2021)

All I can suggest is to open a bug here:









						GitHub - jrmarino/synth: Next D/Ports build tool for live systems (Alternative for Portmaster and Portupgrade tools)
					

Next D/Ports build tool for live systems (Alternative for Portmaster and Portupgrade tools) - GitHub - jrmarino/synth: Next D/Ports build tool for live systems (Alternative for Portmaster and Portu...




					github.com
				




Marino is a member on these forums so he might answer directly.


----------



## rwv37 (Feb 2, 2021)

OK, will do. Thanks again.


----------



## rwv37 (Feb 3, 2021)

For anyone else interested, the thread is here. The tl/dr:

As I was guessing, there's no real point to the question, since (in order to get things to work consistently) you have to later do a `synth rebuild-repository` regardless of whether you answer yes or no. The question was put in just to stop some users from complaining about something they didn't understand.

It is suggested to never use `synth build`. Instead, use `synth just-build`, which will skip the question entirely.

All in all, a good way to update using synth is this (checking the output of each step to make sure there's no reason to back off and do something differently, of course):

portsnap fetch update
pkg updating | more
synth status _{top-level-packages-filename}_
synth just-build _{top-level-packages-filename}_
synth rebuild-repository
pkg upgrade -r Synth
pkg autoremove


----------

