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

shell: Ensure the history file always exists #232

Merged
merged 2 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ development source code and as such may not be routinely kept up to date.

# __NEXT__

## Bug fixes

* `nextstrain shell` no longer errors when its history file, e.g.
_~/.nextstrain/shell-history_, doesn't exist. This primarily affected the
Docker runtime and was a regression from 4.2.0 introduced in 5.0.0.
([#232](https://github.com/nextstrain/cli/pull/232))


# 5.0.0 (25 October 2022)

Expand Down
15 changes: 14 additions & 1 deletion nextstrain/cli/command/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ def run(opts):
print()

with resources.as_file("bashrc") as bashrc:
history_file = SHELL_HISTORY
# Ensure the history file exists to pass checks the Docker runner
# performs for mounted volumes. This also makes sure that the file is
# writable by the Conda runtime too by ensuring the parent directory
# exists.
#
# Don't use strict=True because it's ok if it doesn't exist yet!
history_file = SHELL_HISTORY.resolve()
history_file.parent.mkdir(parents = True, exist_ok = True)

try:
# Don't use exist_ok=True so we don't touch the mtime unnecessarily
history_file.touch()
except FileExistsError:
pass

if opts.__runner__ is conda:
opts.default_exec_args = [
Expand Down