Skip to content

_frontend/cli.py: Report a relative bst shell --mount path as an error - #2220

Open
Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/shell-relative-mount
Open

Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/shell-relative-mount

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

bst shell --mount HOSTPATH PATH with a relative PATH, as in the issue, loads and stages the element and then trips the assertion in Sandbox.mark_directory(), which shows up as a BUG with a traceback.

The mount paths are now checked in the shell command, after _HostMount has expanded environment variables in them, so a quoted '$HOME/src' that expands to an absolute path still works. A relative path raises an AppError (reason relative-mount-path), and the command fails with a normal error message before anything is staged. The option's help now says that PATH has to be absolute. The sandbox assertion stays as it is.

Relative paths in project.conf shell: host-files go through the same mark_directory() call. I left those out here, since they are project configuration and would be better reported at load time, like #2077.

I added a test in tests/integration/shell.py. It builds the element first, so on master it hits the assertion from the issue, and with this change it gets the error. I ran tests/integration/shell.py with --integration and the frontend tests, plus black and pylint, locally.

Fixes #2151

The sandbox only accepts absolute paths to mount at, and checks this
with an assertion. So `bst shell --mount HOSTPATH PATH` with a relative
PATH loaded the element, staged its dependencies and then failed with a
BUG message and a traceback.

Check the paths before running the shell and raise an AppError, so that
the command fails with a normal error message. Also say in the option's
help that PATH has to be absolute.

Fixes apache#2151
Check that `bst shell --mount` reports a relative path in the sandbox
as an error, instead of failing in the sandbox with a BUG message.

This is a part of apache#2151

This branch has not been deployed

No deployments
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 this pull request may close these issues.

bst shell is giving a bug trace when using --mount

1 participant