macos – Apple Terminal startup errors (session save/restore)

0
19
macos – Apple Terminal startup errors (session save/restore)


(Boring replace: it appears that evidently this persists with macOS 15 Sequoia.)

Not too long ago (presumably with the Sonoma replace, however presumably much more lately than 14.0), Apple Terminal has been giving the next error on startup (when macOS is ready to revive home windows, i.e., when System Settings > Shut home windows when quitting… is unset):

date: unlawful time format
utilization: date [-jnRu] [-I[date|hours|minutes|seconds]] [-f input_fmt]
            [-r filename|seconds] [-v[+|-]val[y|m|w|d|H|M|S]]
            [[[[mm]dd]HH]MM[[cc]yy][.SS] | new_date] [+output_fmt]
-bash: Saving: command not discovered

or, within the case of zsh,

/Customers/jaffe/.zsh_sessions/.session:2: command not discovered: Saving

(Generally the error messages are considerably totally different — the issue is clearly considerably “non-deterministic” attributable to no matter race situation is occurring.)

Since initially posting this query (see updates beneath), it has develop into clear that the error seems to occur in a number of variations of macOS, on Intel and Apple Silicon. It does not look like attributable to put in software program or config recordsdata.

I’ve traced this to an error coming from /and so forth/bashrc_Apple_Terminal (or /and so forth/zshrc_Αpple_Terminal) which is essentially involved with saving and restoring periods for the varied terminal tabs and home windows. (A lot of the following will particularly confer with the signs with bash however it’s comparable for zsh.)

It comes from the traces

    if [ -r "$SHELL_SESSION_FILE" ]; then
    . "$SHELL_SESSION_FILE"
    rm "$SHELL_SESSION_FILE"
    fi

On shell startup, this snippet runs, after which deletes, "$SHELL_SESSION_FILE", which is written at shell exit by the next traces:

    if [ -n "$SHELL_SESSION_FILE" ]; then
        echo -ne 'nSaving session...' >&2
        (umask 077; echo 'echo Restored session: "$(/bin/date -r '$(/bin/date +%s)')"' >| "$SHELL_SESSION_FILE")
        declare -F shell_session_save_user_state >/dev/null && shell_session_save_user_state
        shell_session_history_allowed && shell_session_save_history
        echo 'accomplished.' >&2
    fi

The error happens as a result of $SHELL_SESSION_FILE incorrectly comprises the next textual content:

Saving session...echo Restored session: "$(/bin/date -r 1698759014 Saving session...)"

quite than echo Restored session: "$(/bin/date -r 1698759014)
For some motive, the Saving session... textual content is showing within the file (twice!) — it’s being despatched to "$SHELL_SESSION_FILE" quite than stderr (by way of >&2).

I suppose I did not make any adjustments to trigger this, however maybe I’m fallacious. The listing ~/bash_sessions/ appears to have current recordsdata with this error, and barely older recordsdata (as current as yesterday!) which do not. I often replace numerous packages with homebrew, and I’ve lately put in Python 3.12 from python.org, however I can not see how they might attain into the heart of shell startup.


Replace: The truth is, I see this even with a brand new consumer, and even when I exploit zsh quite than bash! (Apple Terminal has very comparable code for session historical past administration underneath zsh.) So it appears that evidently another current change to my system is inflicting this. However I think it is not merely a Sonoma downside, because it doesn’t look like widespread. Yikes!

Replace 1a: Notice that the code is run by way of lure shell_session_update EXIT. The error solely appears to occur once I exit the shell by quitting Terminal.app, however not once I simply use the exit command. (And I’ve even tried explicitly sending numerous alerts to the shell by way of kill -n, however I can not seem to induce the error that method.)

Replace 2: A minimum of one different particular person is seeing this! Maybe this means a difficulty with VS Code?

Replace 3: After some forwards and backwards within the feedback beneath, it’s clear that the error spans a number of variations of macOS on each Intel and Apple Silicon architectures, and we appear to have eradicated VS Code and presumably Python (we appear to be utilizing totally different variations and installers) because the trigger; I’ve eliminated /choose/homebrew and rebooted and nonetheless seeing the difficulty. Is it potential that any of this stuff one way or the other “pollutes” the setting — e.g., /and so forth/ — in a roundabout way that continues to be in place?

Replace 4: Impressed by an interplay over on TidBits, I attempted utilizing Howard Oakley’s wonderful sandboxed light-weight VM, ViableS. I put in nothing, nada, zip, and added no recordsdata to ~/ or anyplace else. However after beginning and restarting Terminal.app with just a few tabs, and making certain that “shut home windows when quitting” is unset, I instantly received the message

/Customers/jaffe/.zsh_sessions/.session:2: command not discovered: Saving

This appears to level, practically conclusively, to a macOS bug. However I nonetheless do not perceive how there are individuals reporting not seeing it.


Is anybody else seeing this? Is anybody explicitly not seeing it? Any concepts what’s taking place (and even debugging options)?

I’ve requested a extra particular model of this query over on Unix & Linux SA.

LEAVE A REPLY

Please enter your comment!
Please enter your name here