Hm, now I cannot reproduce this anymore. But today I got this bug,
recompiled Emacs from Git and the bug was still there. Right now I
tested Emacs 28 in case I managed to switch them accidentally, but
no, also not there.

So, either I have mixed something up, or this depends on some
volatile state in TRAMP, e.g. its cache.

I guess you can close the bug.

Paul

On Wed, 14 Sept 2022 at 20:08, Lars Ingebrigtsen <larsi@gnus.org> wrote:
Paul Pogonyshev <pogonyshev@gmail.com> writes:

> Git commit fd1ee05977.
>
> Open any file with TRAMP. From this buffer, evaluate:
>
>     (let ((file buffer-file-name)) (with-temp-buffer (insert-file-contents file nil)))
>
> This works fine. However, if you use a region:
>
>     (let ((file buffer-file-name)) (with-temp-buffer (insert-file-contents file nil 1 10)))
>
> this fails with an obviously wrong (file is certainly there) signal:
>
>     Debugger entered--Lisp error: (file-missing "/ssh:...")
>       signal(file-missing ("/ssh:..."))

I tried this recipe with the current trunk, and things worked fine for
me.

Is it possible that you have an old version of tramp somewhere in your
load path?  I seem to vaguely recall that insert-file-contents +
start/end was something that was fixed sometime last year.