Fossil Forum
Post: Switching primary and secondary repos in a shared server
In a Linux server with several accounts, we started de development of a new piece of software using fossil in the account bl_ddd. The repo path is /home/bl_ddd/var/lib/fossil/hcollections.fossil.
Then we realized that the primary account for this development should be another one, called ddd. So, from this ddd account, we cloned the fossil repo this way:
ddd@estrada:~/var/lib/fossil$ fossil clone --no-open --once /home/bl_ddd/var/lib/fossil/hcollections.fossil
This one (ddd) being the primary, from the other account (bl_ddd) we set the remote this way:
bl_ddd@estrada:~/hcollections$ fossil remote add file:///home/ddd/var/lib/fossil/hcollections.fossil
So far, so good. After opening the repo, we have done some commits from this ddd account, but then we cannot update the repo of other one, bl_ddd. We get this message, as is there would be no local clone:
bl_ddd@estrada:~/hcollections$ fossil update
Pull from file:///home/ddd/var/lib/fossil/hcollections.fossil
Database error: "/home/ddd/var/lib/fossil/hcollections.fossil" is readonly.
attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Error: Database error: attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Pull done, wire bytes sent: 293 received: 372 remote:
Autosync failed.
continue in spite of sync failure (y/N)? n
update abandoned due to sync failure
How have we done wrong? We have tried it several times, with and whithout --once when cloning it. We have also removed the "secondary" repo and cloned it again, but the error message is always the same.
Thanks,
Ferran
How have we done wrong?
Assuming I understand your situation correctly...
When using Fossil with local files (e.g. the file:// transport) it is no different than any other tool that requires proper filesystem permissions to use. Fossil cannot grant privileges above what the filesystem permits (e.g. there is no privilege escalation in Fossil). If the directory or file that does not permit user "bl_ddd" to change things, then you'll get errors no matter what tool you use, be it Fossil, ls, cat, less, vi, etc.
What are the permissions on:
$ ls -l /home/ddd/var/lib/fossil/hcollections.fossil
Does the "bl_ddd" user have access to it? It sounds like the only access "bl_ddd" has is read-only access. If you intend to have multiple users accessing this file then you should probably create a group and add those users that should be in the group. Then set the permissions on the "remote" file to allow writing from the group.
You may also need to set the permissions correctly on the directories leading up to that file as well.
It looks like you're under the impression that a clone should be possible with a readonly SQLite DB. It isn't, as you see.
This is not specific to your local setup. A fossil server instance would fail on a readonly repo DB for the same basic reason.
If you need two accounts on the same machine with write access to the DB, put them in the same Unix group and set file and directory permissions appropriately.
Both users, ddd and bl_ddd belong to the same Unix group (users), and that's why I have been able to clone the repo in any direction. The problem is when I try to syncronize, that is: read from remote, write to local. I amb not able to do it. Not with fossil update, bot neither with fossil sync nor fossil pull:
bl_ddd@estrada:~/hcollections$ fossil remote
file:///home/ddd/var/lib/fossil/hcollections.fossil
bl_ddd@estrada:~/hcollections$ fossil status
repository: /home/bl_ddd/var/lib/fossil/hcollections.fossil
local-root: /home/bl_ddd/hcollections/
config-db: /home/bl_ddd/.fossil
checkout: a1a30562fff14f759f597a71b82e9bbc2cfb7b66 2026-11-10 09:51:03 UTC
parent: 61fed388e3f45a5d5d6d0d1848b364ddcfb7a069 2026-11-10 09:24:02 UTC
tags: trunk
comment: Fix migration class name (user: fjorba)
bl_ddd@estrada:~/hcollections$ fossil sync
Sync with file:///home/ddd/var/lib/fossil/hcollections.fossil
Database error: "/home/ddd/var/lib/fossil/hcollections.fossil" is readonly.
SQL error (8,8: attempt to write a readonly database) while running [DELETE FROM private WHERE rid=:rid]
Round-trips: 1 Artifacts sent: 0 received: 0
Error: Database error: SQL error (8,8: attempt to write a readonly database) while running [DELETE FROM private WHERE rid=:rid]
Round-trips: 1 Artifacts sent: 0 received: 0
Sync done, wire bytes sent: 5843 received: 346 remote:
bl_ddd@estrada:~/hcollections$ fossil pull
Pull from file:///home/ddd/var/lib/fossil/hcollections.fossil
Database error: "/home/ddd/var/lib/fossil/hcollections.fossil" is readonly.
attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Error: Database error: attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Pull done, wire bytes sent: 295 received: 372 remote:
Edit reply: Switching primary and secondary repos in a shared server
Well, the (initial) clone is possible, but I'm not able to do is to receive updates from the remote (owned by another user) repo to the local (owned by me). If I can do it from a remote (http) fossil server, why I cannot do it from a local (file) one?
the (initial) clone is possible
Clone and sync aren't the same thing. Opening a repo does a sync unless you give --nosync.
If I can do it from a remote (http) fossil server…
That fossil server instance is the sole owner of the DB in that case. It is the Fossil RBAC that governs permission in that case, not Unix file permissions.
Z
I see. Thanks for the pointer. We'll take a look at the permissions.
We have tried adding the o (= Check out code) to all users, including nobody and anonymous, in the primary repo, but the error remains the same. Even with developer capabilities. From the secondary repo we cannot get updates (pull, sync or update) from the remote one. They all complain that the remote repo is readonly.
We have updated remote repos using ssh and http protocols, and they have been working fine since several months, and it is great, thanks!. But it is strange that the file protocol, that should be the simplest, doesn't.
Both users, ddd and bl_ddd belong to the same Unix group (users),
What are the permissions on the file?
$ ls -l /home/ddd/var/lib/fossil/hcollections.fossil
What are the permissions on the directory?
$ ls -ld /home/ddd/var/lib/fossil
When you are using the filesystem as the sync transport the only thing that matters is the Unix filesystem permissions. Changing permissions in Fossil is not relevant.
Understood. Bug we have read access:
bl_ddd@estrada:~/hcollections$ ls -l /home/ddd/var/lib/fossil/hcollections.fossil
-rw-r--r-- 1 ddd users 356352 Nov 12 16:04 /home/ddd/var/lib/fossil/hcollections.fossil
bl_ddd@estrada:~/hcollections$ ls -ld /home/ddd/var/lib/fossil
drwxr-xr-x 2 ddd users 4096 Nov 12 16:04 /home/ddd/var/lib/fossil
bl_ddd@estrada:~/hcollections$ sqlite3 /home/ddd/var/lib/fossil/hcollections.fossil
SQLite version 3.46.1 2024-08-13 09:16:08
Enter ".help" for usage hints.
sqlite> .tables
accesslog cherrypick filename plink tag unsent
artifact concealed leaf private tagxref user
attachment config mlink rcvfrom ticket
backlink delta orphan reportfmt ticketchng
blob event phantom shun unclustered
sqlite> select count(*) from artifact;
169
Understood. ButL@3G,8:
1I@3f,1:
1O@4x,3:
a@3f,1:dP@4F,1:
12@7K,3:
W@3f,7:sqlite3i@4F,1:
f@9g,1:
V@AL,I:
sqlite> .tables
1D@B4,1:
1D@CH,1:
10@DU,1:
10@EU,1:
10@FU,1:
c@GU,j:
169
Z cb7504fc9231014954124a7ec20dd263 1TpWpw;
But we have read access:
Is your goal to allow a read-only clone (and pulling) of the repository but not to allow commits?
We have tried it several times,
What version of Fossil are you using on this Linux system?
attempt to write a readonly database:
Write, not read rights need you.
Well, both are needed, to be fair to Yoda.
both are needed,
Upon intent it depends.
If the intent is to provide a read-only clone where changes are not permitted to be pushed then probably what the OP wants is to configure:
bl_ddd@estrada:~/hcollections$ fossil settings autosync pullonly
If you're still using file:/// remotes, RBAC settings won't have any effect. That only works straightforwardly with http:// access, or via cleverness, ssh:// ones.
Yes, that would be perfectly acceptable in that case. Because it is obvious that without write access we cannot commit to the remote repo.
Fossil 2.28, downloaded from https://fossil-scm.org/home/uv/download.html. Debian Stable has a sligthly older one, but we wanted to test it with the newest available.
Thanks for the idea. Done it, but again, for any operation (update, pull or sync) we still get the same error:
bl_ddd@estrada:~/hcollections$ fossil settings autosync pullonly
bl_ddd@estrada:~/hcollections$ fossil settings
[...]
autosync (local) pullonly
[...]
bl_ddd@estrada:~/hcollections$ f status
repository: /home/bl_ddd/var/lib/fossil/hcollections.fossil
local-root: /home/bl_ddd/hcollections/
config-db: /home/bl_ddd/.fossil
checkout: a1a30562fff14f759f597a71b82e9bbc2cfb7b66 2026-11-10 09:51:03 UTC
parent: 61fed388e3f45a5d5d6d0d1848b364ddcfb7a069 2026-11-10 09:24:02 UTC
tags: trunk
comment: Fix migration class name (user: fjorba)
bl_ddd@estrada:~/hcollections$ fossil sync
Pull from file:///home/ddd/var/lib/fossil/hcollections.fossil
Database error: "/home/ddd/var/lib/fossil/hcollections.fossil" is readonly.
attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Error: Database error: attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Pull done, wire bytes sent: 294 received: 372 remote:
but the error message is always the same.
The error message is there because you have a number of unclustered artifacts in:
/home/ddd/var/lib/fossil/hcollections.fossil
The "server" side of things wants to clean this up by clustering them, but because it's read-only to bl_ddd it cannot do so.
The rest of what I have to say is based upon the assumption that you really do want bl_ddd to have no permissions to write to that file and that it should be read-only access.
Normally, when content is pushed into a repository the artifacts are added to the unclustered table and then when the "server" notices that there are sufficient unclustered artifacts, it will create a new cluster artifact and clear the table.
Because your "server" (the file://) is read-only to bl_ddd, it cannot clean those up.
Presumably you have "opened" the "server" file directly as the ddd user:
/home/ddd/var/lib/fossil/hcollections.fossil
However, with Fossil's current design you should instead make clones of it by those who want to commit. In effect, you need to treat that file as if it's a "server" and not make direct modifications to it, i.e. do not "open" it and make commits to it. All content should be "pushed" to it by those who have permissions (filesystem permissions).
So, for example, the ddd user should do something like:
fossil clone /home/ddd/var/lib/fossil/hcollections.fossil /home/ddd/myrepos/hcollections.fossil fossil open --workdir /home/ddd/src/hcollections /home/ddd/myrepos/hcollections.fossil
All work that ddd does should be against his clone in his working checkout of the repository:
/home/ddd/src/hcollections
Then when he commits something, it should automatically update the unclustered table in the "server" and your read-only client should have no trouble pulling.
Yes, sorry, it was a mistake on my part to suggest it (unless you intend to commit changes by bl_ddd but don't want them pushed up to the "server").
The real problem is the fact that bl_ddd cannot run the "server" with sufficient filesystem permissions to allow the unclustered table to be cleaned. I described the situation in a separate post already.
Please read that and follow up with any questions.
Thanks again for your help. I don't full understand this unclustered artifacts issue. I've searched in the Fossil site and there is not much information. In my repo there are 169 records in this table. I haven't found any way to "clean it".
Anyway, I've renamed the old stuff, I've followed your instructions, and now I'm unable top open my repo:
bl_ddd@estrada:~/var/lib/fossil$ fossil clone /home/ddd/var/lib/fossil/hcollections.fossil ~/var/lib/fossil/hcollections.fossil
Repository cloned into /home/bl_ddd/var/lib/fossil/hcollections.fossil
Rebuilding repository meta-data...
100.0% complete...
Extra delta compression... none found
Vacuuming the database...
project-id: 9d9b2a724479acbaa939d6e67c0354b2d576aae5
server-id: 3865d20edef8e1c77df5514fcc7d75c2cd6d68a1
admin-user: fjorba (password is "xxxxxx")
bl_ddd@estrada:~$ fossil open --workdir hcollections ~/var/lib/fossil/hcollections.fossil
Pull from file:///home/ddd/var/lib/fossil/hcollections.fossil
Database error: "/home/ddd/var/lib/fossil/hcollections.fossil" is readonly.
attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Error: Database error: attempt to write a readonly database: {DELETE FROM unclustered WHERE rid NOT IN (0 ) AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)}
Round-trips: 1 Artifacts sent: 0 received: 0
Pull done, wire bytes sent: 294 received: 372 remote:
Autosync failed.
continue in spite of sync failure (y/N)? n
unable to auto-sync the repository
Our goal was to use Fossil as a software distribution (file syncronization) tool, as we have been done successfully in other cases. We don't want to keep them syncronized automatically, just when a new release is ready. So, the fossil update would be trigged manually by us.
In this same server we have several other Fossil repos that we syncronize via http, so we have the infrastructure ready (Nginx + scgi). We thought that in this particular case we didn't need so many layers, and the file protocol would be much simpler. If it turns out that this is not possible to do with the file protocol, we can use the http one. So is that the conclusion?
I haven't found any way to "clean it".
Maybe you haven't seen this post yet:
https://fossil-scm.org/forum/forumpost/90e8f5d8797c0b41
So is that the conclusion?
No, this is not the conclusion. You can use the file transport for synchronization if you want with a read-only client, however, it requires that you set it up correctly.
I've followed your instructions, and now I'm unable top open my repo:
If you did indeed follow the instructions, have you pushed any new content into the "server"? Or even run "fossil pull" from ddd who has permission to write to the file?
As the ddd user try running:
fossil pull -R /home/ddd/myrepos/hcollections.fossil
This should trigger a rebuild of the clusters on the main repository.
I don't full understand this unclustered artifacts issue.
It's not something that comes up very often as it's quite unnecessary for most people to understand how they work. In general they just work behind the scenes, but in your case you are trying to access a repository with the file:// transport using read-only permissions, and therefore your "server" (which runs as bl_ddd) isn't able to update the unclustered table because bl_ddd does not have filesystem permissions to do so.
Which means you'll need to have a file:// that sends and receives its content via the sync protocol and that same file:// should be cloned by your read-only users.
If you really want to know more about clusters:
https://fossil-scm.org/home/doc/trunk/www/sync.wiki#phantoms https://fossil-scm.org/home/doc/trunk/www/sync.wiki#unclustered https://fossil-scm.org/home/doc/trunk/www/sync.wiki#strategies
You'll notice in that last URL that it discusses how the unclustered table is updated on the server, and in particular step 5.
Well, when you are using a file:// synchronization transport in read-only mode, who is running the server and does that someone have filesystem permissions to update them? In your case, with bl_ddd, the answer is no. This doesn't mean it cannot be run with read-only users, it just needs more careful planning.
If you did indeed follow the instructions, have you pushed any new content into the "server"?
Yes, one commit.
Or even run "fossil pull" from ddd who has permission to write to the file?
Yes, from the "secondary" account.
fossil pull -R /home/ddd/myrepos/hcollections.fossil
Or I'm completely confused (most likely) or this doesn't work either
ddd@estrada:~/hcollections$ fossil pull -R ~/var/lib/fossil/hcollections.fossil
Usage: fossil pull URL
ddd@estrada:~/hcollections$ fossil pull -R ~/var/lib/fossil/hcollections.fossil
Usage: fossil pull URL
We thought that the file protocol would be the simplest in our case. As it doesn't seems so, and I'unable to "set it properly", I think we'll use the http protocol like the others.
Again, I sincerely appreciate your explanations. But it seems that I'm not able to set this "careful planning" to use the file protocol. We'll try to switch to the http protocol, as it has been working wonderfully before.
If you did indeed follow the instructions, have you pushed any new content into the "server"?
Yes, one commit.
Or even run "fossil pull" from ddd who has permission to write to the file?
Yes, from the "secondary" account.
fossil pull -R /home/ddd/myrepos/hcollections.fossil
Or I'm completely confused (most likely) or this doesn't work either
ddd@estrada:~/hcollections$ ls -l ~/var/lib/fossil/hcollections.fossil
-rw-r--r-- 1 ddd users 356352 Nov 12 16:04 /home/ddd/var/lib/fossil/hcollections.fossil
ddd@estrada:~/hcollections$ fossil pull -R ~/var/lib/fossil/hcollections.fossil
Usage: fossil pull URL
Maybe you haven't seen this post yet:
https://fossil-scm.org/forum/forumpost/90e8f5d8797c0b41
Yes, thanks.
We thought that the file protocol would be the simplest in our case. As it doesn't seems so, and I'unable to "set it properly", I think we'll use the http protocol like the others.
The -R <repo> option is to tell fossil to act on the repository <repo> when your current directory is not inside an open checkout.
- It's not "from where to pull".
Where to pull is recorded in the repo at clone, on 1st pull/push/sync command or using the dedicated command remote.
- In your case, it seems that ~/var/lib/fossil/hcollections.fossil never had a recorded remote to pull from.
(This is why you get the "Usage: fossil pull URL" error.)
Assuming ~/hcollections here is the opened checkout of the other repo (which is inside the bl_ddd user homedir) when looking at your first post.
(your current user is ddd, so ~/ = /home/ddd)
-
So calling
fossil pullwithout the-Rwill act on the "/home/bl_ddd/var/lib/fossil/hcollections.fossil" repo -
If your intent was to do:
ddd -> bl_ddd, you need to dofossil pull ~/var/lib/fossil/hcollections.fossil
(this will record it as your default remote, file path doesn't need to be specified next time)
-
If it's the opposite:
bl_ddd -> ddd, since your opened checkout is from the repo in /home/bl_ddd/... you can usepushinstead ofpull.fossil push ~/var/lib/fossil/hcollections.fossil
You can use fossil info from the checkout to confirm this is the checkout of which repo exactly.
You can call fossil remote any time to just show what is the current remote (the other repo pull/push/sync or commit/update(when autosync is on).
Usage: fossil pull URL
This error is a bit misleading in my opinion. It means that you don't have a "remote" setup in ~/var/lib/fossil/hcollections.fossil
What you really want, however, is for ddd to clone this file and make modifications there. Again, as ddd:
fossil clone ~/var/lib/fossil/hcollections.fossil ~/museum/hcollections.fossil
Then run:
fossil pull -R ~/museum/hcollections.fossil
If you need to make modifications, then you open that repository, NOT the canonical one:
fossil open ~/museum/hcollections.fossil --workdir ~/src/hcollections
When you make changes in ~/src/hcollections and commit them, autosync should first run "pull".
Then your read-only user bl_ddd should have no problems cloning ~/var/lib/fossil/hcollections.fossil and pulling from it.
Thanks for the clarification. I didn't expect all those subtilities cloning and (pretending to) updating a repo using the file protocol, when it we had some very satisfactory experience using ssh or http. Anyway, we are very happy with Fossil despite of this case. Thanks.