Help with "Block error"

Hi. I’m encountering an issue when I try to record a change. Namely, I get the error: “Error: Block error: Position { change: ChangeId(SOME_VALUE), pos: ChangePosition(L64(9209)) }”. Here’s a reproduction:

$ pijul clone https://nest.pijul.com/nicoty/exercism_solutions
Downloading changes [==================================================] 11/11
           Applying [==================================================] 11/11
 Completing changes [                                                  ] 0/0
$ cd exercism_solutions
$ # Add new files and directories to this local repository.
$ pijul add -r ./
$ pijul record
Password for "/home/a/.config/pijul/secretkey.json": # I then add patch message after entering the password.
Error: Block error: Position { change: ChangeId(SOME_VALUE), pos: ChangePosition(L64(9209)) }

Every time I run pijul record, the same error occurs but the “SOME_VALUE” inside ChangeId(SOME_VALUE) changes. How do I fix this issue?

My system:

$ pijul --version
pijul 1.0.0-alpha.56
$ uname -a
Linux a 5.15.9_1 #1 SMP Thu Dec 16 17:16:21 UTC 2021 x86_64 GNU/Linux

Hi! Thanks for your report. We’re in the process of finishing up a full stable version (coming in the next few days/weeks), and there is a number of issues to tackle at the same time.

Is this from the latest Pijul from nest.pijul.com/pijul/pijul, or from crates.io?

It’s from nixpkgs which afaiu pulls from crates.io (since the derivation uses the fetchCrate function).

If you can, trying the latest version out could solve this. If not, I’m interested by a bug report at nest.pijul.com/pijul/pijul/discussions

I’m trying to clone the repository so I can build the latest version, but I keep encountering an issue:

$ pwd
/home/.shared/repositories/pijul/pijul
$ pijul clone http://nest.pijul.com/pijul/pijul
Downloading changes [=>                                                ] 16/714
           Applying [=>                                                ] 16/714
Error: Changestore error: failed to fill whole buffer
$ pijul clone http://nest.pijul.com/pijul/pijul
Downloading changes [>                                                 ] 13/714
           Applying [>                                                 ] 13/714
Error: Changestore error: failed to fill whole buffer
$ pijul clone http://nest.pijul.com/pijul/pijul
Downloading changes [>                                                 ] 6/714
           Applying [>                                                 ] 6/714
Error: Changestore error: failed to fill whole buffer

I can’t reproduce. From what country are you trying to download this?

I’m trying to download from the United Kingdom.

Same mirror as mine (but an older Pijul), I don’t really understand. An alternative you can try is via SSH. If you have an account on the Nest, and have uploaded your SSH key, you can do:

pijul clone login@ssh.pijul.com/pijul/pijul

Also, sorry for all these issues, I was expecting the final stages before the beta to be slightly smoother.

Edit: Ah nevermind. I just tried it again and it worked this time. Now I’ll try to build it!

Original: Now I’m getting:

$ pijul clone nicoty@ssh.pijul.com/pijul/pijul
Password for key "id_ed25519":
Password for nicoty@ssh.pijul.com:
Downloading changes [============>                                     ] 172/714
           Applying [=========>                                        ] 135/714
Well, this is embarrassing.

pijul had a problem and crashed. To help us diagnose the problem you can send us a crash report.

We have generated a report file at "/tmp/report-6e39d602-d80f-4f0d-80d9-9a4ab0f148b5.toml". Submit an issue or email with the subject of "pijul Crash Report" and include the report as an attachment.

- Authors: Pierre-Étienne Meunier <pe@pijul.org>

We take privacy seriously, and do not perform any automated error collection. In order to improve the software, we rely on people to submit reports.
Downloading changes [============>                                     ] 180/714
           Applying [============>                                     ] 181/714
Error: Changestore error: No such file or directory (os error 2)
$ \cat /tmp/report-6e39d602-d80f-4f0d-80d9-9a4ab0f148b5.toml
name = 'pijul'
operating_system = 'unix:Unknown'
crate_version = '1.0.0-alpha.56'
explanation = '''
Panic occurred in file 'src/remote/ssh.rs' at line 491
'''
cause = 'called `Result::unwrap()` on an `Err` value: Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }'
method = 'Panic'
backtrace = '''

   0: 0x55ff760c78a3 - core::result::unwrap_failed::hcd8e16a338c4f01c
   1: 0x55ff761b0db8 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h60aaf3fbdfa5310e
   2: 0x55ff7619b5a4 - thrussh::client::encrypted::<impl thrussh::client::Session>::client_read_authenticated::{{closure}}::h1a6260601126f021
   3: 0x55ff761c3181 - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::he0465aecf708bfab
   4: 0x55ff761978ec - thrussh::client::Session::run::{{closure}}::h797987c5dee3ac8f
   5: 0x55ff7618e163 - tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::h116c7101ed71368e
   6: 0x55ff7613aa89 - tokio::runtime::task::harness::Harness<T,S>::poll::h2a05342f8e5a505b
   7: 0x55ff765aa84f - std::thread::local::LocalKey<T>::with::h0c7b1c5fdfc1c774
   8: 0x55ff765a1d94 - tokio::runtime::thread_pool::worker::Context::run_task::h203fd8e5f4744edb
   9: 0x55ff765a1072 - tokio::runtime::thread_pool::worker::Context::run::h9a6fd49abd63d0dc
  10: 0x55ff765afb15 - tokio::macros::scoped_tls::ScopedKey<T>::set::ha42f6f4e5b527027
  11: 0x55ff765a0bfc - tokio::runtime::thread_pool::worker::run::h7f50cfe718fc70ed
  12: 0x55ff765912ef - tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::he355a39d8d000d65
  13: 0x55ff765949f8 - tokio::runtime::task::harness::Harness<T,S>::poll::h6df38a78aaa237e3
  14: 0x55ff7658ab62 - tokio::runtime::blocking::pool::Inner::run::h32c4f8553799fa85
  15: 0x55ff765adbde - std::sys_common::backtrace::__rust_begin_short_backtrace::h6e34c645afcd62ae
  16: 0x55ff765ae268 - core::ops::function::FnOnce::call_once{{vtable.shim}}::hcf6441e9d6bbced6
  17: 0x55ff769469c3 - std::sys::unix::thread::Thread::new::thread_start::h0ad17abd9105a960
  18: 0x7f9cd4a8ed3e - start_thread
  19: 0x7f9cd487343f - __clone
  20:        0x0 - <unresolved>'''
$

I seem to be encountering the same issue even when using the latest version from the repo:

$ pwd
/home/.shared/repositories/pijul/pijul/pijul
$ pijul log | \cat
Change SH2ZBSAZNP3K5F5H7H5LJJUP3F2T4VKA53WLKJMQJ5CRRWU733JQC
Author: DoQo9ZrP1CpCvMB8Qd6CNunvTAQYuQEveQurCvnhcW7M
Date: 2021-12-20 14:47:45.602405764 UTC

    Fix typo in flake.nix defaultPackage

# Rest of the log ommitted.
$ nix-shell

[nix-shell:/home/.shared/repositories/pijul/pijul/pijul]$ cd /home/.shared/projects/exercism_solutions

[nix-shell:/home/.shared/projects/exercism_solutions]$ pijul record
Password for "/home/a/.config/pijul/secretkey.json":
Error: Block error: Position { change: ChangeId(SHJNOYSACDTXQ), pos: ChangePosition(L64(9209)) }

[nix-shell:/home/.shared/projects/exercism_solutions]$

I’m assuming that running nix-shell from the directory of the local repository will build pijul and expose it in my $PATH (replacing the old version), allowing me to use that latest version in that shell. Is that correct?

nix-shell won’t but the new flake-based nix shell will

Note that the Cargo.nix was outdated for me so you’ll also need to…

nix develop
cargo check
crate2nix generate

@nicoty: can you clone your repository anew, and start from that clone? There is a possibility that the version you used corrupted the repo, cloning should fix that.

I still seem to be encountering the same issue in spite of doing your suggestions:

$ pijul clone nicoty@ssh.pijul.com/pijul/pijul
Password for key "id_ed25519":
Password for nicoty@ssh.pijul.com:
Downloading changes [==================================================] 714/714
           Applying [==================================================] 714/714
 Completing changes [                                                  ] 0/0
$ cd pijul
$ pijul log | \cat
Change SH2ZBSAZNP3K5F5H7H5LJJUP3F2T4VKA53WLKJMQJ5CRRWU733JQC
Author: DoQo9ZrP1CpCvMB8Qd6CNunvTAQYuQEveQurCvnhcW7M
Date: 2021-12-20 14:47:45.602405764 UTC

    Fix typo in flake.nix defaultPackage

# Rest of the log ommitted.
$ nix --extra-experimental-features nix-command --extra-experimental-features flakes develop
bash-5.1$ cargo check
    Updating crates.io index
# Rest of output ommitted.
    Checking pijul v1.0.0-alpha.56 (/home/.shared/repositories/pijul/pijul/pijul/pijul)
warning: field is never read: `tags`
   --> pijul/src/remote/mod.rs:190:5
    |
190 |     pub tags: HashSet<Merkle>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(dead_code)]` on by default

warning: `pijul` (bin "pijul") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 6m 33s
bash-5.1$ crate2nix generate
Generated ./Cargo.nix successfully.
bash-5.1$ nix --extra-experimental-features nix-command --extra-experimental-features flakes shell
bash-5.1$ cd /home/.shared/projects
bash-5.1$ \rm -fr exercism_solutions
bash-5.1$ pijul clone nicoty@ssh.pijul.com/nicoty/exercism_solutions
Password for key "id_ed25519":
Password for nicoty@ssh.pijul.com:
Downloading changes [==================================================] 11/11
           Applying [==================================================] 11/11
 Completing changes [                                                  ] 0/0
bash-5.1$ cd exercism_solutions
bash-5.1$ # Add new files and directories to this local repository.
bash-5.1$ pijul add -r ./
bash-5.1$ pijul record
Password for "/home/a/.config/pijul/secretkey.json": # Add patch message after entering the password here.
Error: Block error: Position { change: ChangeId(MDWMGOT7CFGZC), pos: ChangePosition(L64(9209)) }
bash-5.1$

I can confirm, that there is some problem.

Using the current version of pijul (built with nix from the Nest).

$ pijul clone https://nest.pijul.com/nicoty/exercism_solutions
Error: No such file or directory (os error 2)
$ pijul clone ssh://...@ssh.pijul.com/nicoty/exercism_solutions
# works fine

Cloning pijul/pijul via https works fine.

I was able to record patches in exercism_solutions, though.

I just discovered something. The issue occurs if I do these steps:

  • pijul clone the repo.
  • Add new files and directories to the local repo.
  • pijul add -r ./ the new files and directories.
  • pijul record a patch.

Or if I do:

  • pijul clone the repo.
  • pijul record a patch.
  • Add new files and directories to the local repo.
  • pijul add -r ./ the new files and directories.
  • pijul record --amend the previous patch.

But it doesn’t occur if I do the following instead:

  • pijul clone the repo.
  • pijul record a patch.
  • Add new files and directories to the local repo.
  • pijul add -r ./ the new files and directories.
  • pijul record another patch.

How should we move forward with this new information in mind?

I’ve ended up initialising a new repository and replaying the patchset from the older repository. I no longer seem to encounter the issue with this new repository and I’d like to use nicoty/exercism_solutions for it, so I’ve reuploaded the problematic repository to nicoty/exercism_solutions_bugged for posterity. I hope that’s ok.