Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install apps. - Error: Failed to read commit #3479

Closed
arun54321 opened this issue Mar 21, 2020 · 12 comments · Fixed by #4765
Closed

Cannot install apps. - Error: Failed to read commit #3479

arun54321 opened this issue Mar 21, 2020 · 12 comments · Fixed by #4765

Comments

@arun54321
Copy link

Arch linux

flatpak-1.6.2-1

Cannot install apps

flatpak install com.discordapp.Discord                                                                                       [11:41:14]
Looking for matches…
Remotes found with refs similar to ‘com.discordapp.Discord’:

   1) ‘flathub’ (system)
   2) ‘flathub’ (user)

Which do you want to use (0 to abort)? [0-2]: 2
Required runtime for com.discordapp.Discord/x86_64/stable (runtime/org.freedesktop.Platform/x86_64/19.08) found in remote flathub
Do you want to install it? [Y/n]: 

com.discordapp.Discord permissions:
    ipc            network       pulseaudio      x11      devices      file access [1]      dbus access [2]
    tags [3]

    [1] xdg-download, xdg-pictures:ro, xdg-videos:ro
    [2] org.freedesktop.Notifications, org.freedesktop.portal.Fcitx, org.kde.StatusNotifierWatcher
    [3] proprietary


        ID                                Branch          Op          Remote           Download
 1. [✗] org.freedesktop.Platform          19.08           i           flathub             1.0 kB / 238.2 MB
 2. [ ] com.discordapp.Discord            stable          i           flathub          < 69.8 MB

Error: Failed to read commit 3df64a7c249c10d57f920728e03f6e749491f5ab9ecc2d5e8ecdb0fc0a5d92c1: No such metadata object 459a811e4a019a5e022aeb213cef43c5d54c811c10c34c5a8c5cac5ec78bffca.dirtree
error: Failed to install org.freedesktop.Platform: Failed to read commit 3df64a7c249c10d57f920728e03f6e749491f5ab9ecc2d5e8ecdb0fc0a5d92c1: No such metadata object 459a811e4a019a5e022aeb213cef43c5d54c811c10c34c5a8c5cac5ec78bffca.dirtree
@arun54321
Copy link
Author

Running sudo flatpak repair doesn't fix it.

@javashin
Copy link

javashin commented Mar 29, 2020

hi same problem here in gentoo.
error: Failed to install org.freedesktop.Platform: Failed to read commit 3df64a7c249c10d57f920728e03f6e749491f5ab9ecc2d5e8ecdb0fc0a5d92c1: No such metadata object 459a811e4a019a5e022aeb213cef43c5d54c811c10c34c5a8c5cac5ec78bffca.dirtree

EDIT: i fixed this problem. well manually removing /va/lib/flatpak and ./local/share/flatpak the user

and remove .cache on the user dir too and now :

javashin@igloo-l440 ~ $ flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
javashin@igloo-l440 ~ $ flatpak --user install flathub com.spotify.Client org.telegram.desktop

Works just Fine and i also emerged bubblewrap and cp the bwrap binary to where its flatpak-bwrap.

@arun54321
Copy link
Author

Temporary fix - run flatpak repair --user

It looks like it can't resume interrupted downloads.

@DanielVenturini
Copy link

Thanks, @javashin. It works.

@LargePrime
Copy link

@arun54321
thanks fixed me too

@winkdong
Copy link

@arun54321 Thanks, bro! flatpak repair --user Fixed my issue on Clear Linux while installing Scribus Flatpak

@Memorytaco
Copy link

flatpak repair --user should work.

@TheJackiMonster
Copy link

I had a similar issue with org.freedesktop.Sdk.Extension.texlive:

Error: Failed to read commit c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No such metadata object 8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree
error: Failed to install org.freedesktop.Sdk.Extension.texlive: Failed to read commit c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No such metadata object 8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree

flatpak repair --user fixed it but I assume it would be much better if that could trigger automatically by a failing installation like this or if it will at least be provided as option as potential fix in the dialog.

@mwleeds
Copy link
Collaborator

mwleeds commented Feb 19, 2022

I did some digging and figured out a few things but haven't quite found the bug:

  • on the code path where libostree decides to fetch static delta parts, it fetches the .commit and .commitmeta objects into a staging dir in ~/.local/share/flatpak/repo/tmp/staging-...
  • if the download of one of the static delta parts is interrupted, and we hit the error code path where the transaction is aborted, the staging dir will still have those two objects (and possibly others)
  • the next time the installation is attempted, ostree_repo_pull_with_options will complete with a success return value, and the .commit and .commitmeta objects will be copied to the main repo from the staging dir, and the refs/remotes/app/... file will point to the commit, despite the pull not actually being successful
  • in flatpak_dir_deploy(), we call ostree_repo_read_commit() and discover that the commit is not actually complete, that's where the Failed to read commit ... error message comes from.
  • it's possible to "reset" back to the state where the install will try again rather than fail every time by deleting the remote ref file and the commit and commitmeta objects from the local repo
  • so it seems like there's a bug in libostree where it considers a commit object in its staging dir complete and pulls it into the main local repo even if it's not

@mwleeds
Copy link
Collaborator

mwleeds commented Feb 19, 2022

Haven't tested it yet but I think the patch will be just adding a ostree_repo_mark_commit_partial() call in process_one_static_delta() to match the one we have in meta_fetch_on_complete()

mwleeds added a commit to ostreedev/ostree that referenced this issue Feb 19, 2022
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (flatpak/flatpak#3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.
mwleeds added a commit that referenced this issue Feb 19, 2022
All the details of the bug are in:
ostreedev/ostree#2549
#3479

This patch works around it by marking the commit we're about to pull
partial, so that if the .commit object exists in a staging directory
from a previous failed pull, it will not be erroneously considered a
complete commit, even by affected versions of libostree that don't have
the above patch. If for some reason the commit in the staging dir is
complete, libostree should harmlessly verify that and pull it in.

Usually the commit we are pulling does not already exist in the local
repo, but add a check anyway so we don't risk marking a complete commit
as partial, and so this works on the code path from
"flatpak install --reinstall ..."

Fixes #3479
mwleeds added a commit that referenced this issue Feb 20, 2022
All the details of the bug are in:
ostreedev/ostree#2549
#3479

This patch works around it by marking the commit we're about to pull
partial, so that if the .commit object exists in a staging directory
from a previous failed pull, it will not be erroneously considered a
complete commit, even by affected versions of libostree that don't have
the above patch. If for some reason the commit in the staging dir is
complete, libostree should harmlessly verify that and pull it in.

Usually the commit we are pulling does not already exist in the local
repo, but add a check anyway so we don't risk marking a complete commit
as partial, and so this works on the code path from
"flatpak install --reinstall ..."

Fixes #3479
mwleeds added a commit that referenced this issue Feb 21, 2022
All the details of the bug are in:
ostreedev/ostree#2549
#3479

This patch works around it by marking the commit we're about to pull
partial, so that if the .commit object exists in a staging directory
from a previous failed pull, it will not be erroneously considered a
complete commit, even by affected versions of libostree that don't have
the above patch. If for some reason the commit in the staging dir is
complete, libostree should harmlessly verify that and pull it in.

Usually the commit we are pulling does not already exist in the local
repo, but add a check anyway so we don't risk marking a complete commit
as partial, and so this works on the code path from
"flatpak install --reinstall ..."

Fixes #3479
mwleeds added a commit that referenced this issue Feb 21, 2022
All the details of the bug are in:
ostreedev/ostree#2549
#3479

This patch works around it by marking the commit we're about to pull
partial, so that if the .commit object exists in a staging directory
from a previous failed pull, it will not be erroneously considered a
complete commit, even by affected versions of libostree that don't have
the above patch. If for some reason the commit in the staging dir is
complete, libostree should harmlessly verify that and pull it in.

Usually the commit we are pulling does not already exist in the local
repo, but add a check anyway so we don't risk marking a complete commit
as partial, and so this works on the code path from
"flatpak install --reinstall ..."

Fixes #3479

(cherry picked from commit 11158c2)
mwleeds added a commit that referenced this issue Feb 21, 2022
All the details of the bug are in:
ostreedev/ostree#2549
#3479

This patch works around it by marking the commit we're about to pull
partial, so that if the .commit object exists in a staging directory
from a previous failed pull, it will not be erroneously considered a
complete commit, even by affected versions of libostree that don't have
the above patch. If for some reason the commit in the staging dir is
complete, libostree should harmlessly verify that and pull it in.

Usually the commit we are pulling does not already exist in the local
repo, but add a check anyway so we don't risk marking a complete commit
as partial, and so this works on the code path from
"flatpak install --reinstall ..."

Fixes #3479

(cherry picked from commit 11158c2)
dbnicholson pushed a commit to endlessm/ostree that referenced this issue Mar 11, 2022
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (flatpak/flatpak#3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.

(cherry picked from commit 5d3b1ca)
dbnicholson pushed a commit to endlessm/ostree that referenced this issue Mar 11, 2022
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (flatpak/flatpak#3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.

(cherry picked from commit 5d3b1ca)
dbnicholson pushed a commit to endlessm/ostree that referenced this issue Mar 11, 2022
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (flatpak/flatpak#3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.

(cherry picked from commit 5d3b1ca)
raspbian-autopush pushed a commit to raspbian-packages/ostree that referenced this issue Mar 27, 2022
This patch makes it so that we mark the .commit file from a static delta
as partial before writing the commit to the staging directory. This
exactly mirrors what we do in meta_fetch_on_complete() when writing the
commit on that codepath, which should lend some credibility to the
correctness of this patch.

I have checked that this fixes an issue Flatpak users have been
encountering (flatpak/flatpak#3479) which
results in error messages like "error: Failed to install
org.freedesktop.Sdk.Extension.texlive: Failed to read commit
c7958d966cfa8b80a42877d1d6124831d7807f93c89461a2a586956aa28d438a: No
such metadata object
8bdaa943b957f3cf14d19301c59c7eec076e57389e0fbb3ef5d30082e47a178f.dirtree"

Here's the sequence of events that lead to the error:
1. An install operation is started that fetches static deltas.
2. The fetch is interrupted for some reason such as network connectivity
   dropping.
3. The .commit and .commitmeta files for the commit being pulled are
   left in the staging dir, e.g.
   "~/.local/share/flatpak/repo/tmp/staging-dfe862b2-13fc-49a2-ac92-5a59cc0d8e18-RURckd"
4. There is no `.commitpartial` file for the commit in
   "~/.local/share/flatpak/repo/state/"
5. The next time the user attempts the install, libostree reuses the
   existing staging dir, pulls the commit and commitmeta objects into
   the repo from the staging dir on the assumption that it's a complete
   commit.
6. Flatpak then tries to deploy the commit but fails in
   ostree_repo_read_commit() in flatpak_dir_deploy(), leading to the
   error message "Failed to read commit ..."
7. This happens again any subsequent time the user attempts the install,
   until the incomplete commit is removed with "flatpak repair --user".

I will try to also add a workaround in Flatpak so this is fixed even
when Flatpak links against affected versions of libostree.

Bug: flatpak/flatpak#3479
Origin: upstream, 2022.2, commit:5d3b1ca37a508e9f80702b7ef7383fe95253ec6a

Gbp-Pq: Name Fix-marking-static-delta-commits-as-partial.patch
@caio-vinicius
Copy link

flatpak repair
flatpak reapir --user
sudo flatpak repair
sudo flatpak reapir --user

Did not work. I had to rm -rf /var/lib/flatpak and now it's working.

@LargePrime
Copy link

flatpak reapir --user is spelling error, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants