apache / apache/buildstream

Early exit with better error message when launching `bst shell --build` on some elements

Open
#1,001 7 comments 0 reactions 0 assignees View on GitHub
bug frontend logging
Dominant language
Python
Stars
140
Forks
45
Avg merge
1d 3h
Merged PRs (30d)
6

Description

[See original issue on GitLab](https://gitlab.com/BuildStream/buildstream/-/issues/1001)
In GitLab by [[Gitlab user @cs-shadow]](https://gitlab.com/cs-shadow) on Apr 16, 2019, 12:59

## Summary

When trying to launch a build shell on element kinds like `import`, `stack` etc. BuildStream currently gives an error message like: `Staged artifacts do not provide command 'sh'`. This is not technically incorrect but I think we can do better. For example, since the `import` element can't have build dependencies (again, it technically can have them today but that's a separate bug), we know that any build shell on an `import` element is always going to fail with a similar error.

Similarly, `stack` element never stages anything in the sandbox, and as such, is also going to consistently fail.

It would be nice if BuildStream could report better error messages, something like: `'import' element does not allow build shell access`.

## Steps to reproduce

```
# Following steps we are running inside a fresh checkout of BuildStream repository

$ cd doc/examples/first-project
$ bst shell --build hello.bst

Error launching shell: Staged artifacts do not provide command 'sh'
```

## Possible fixes

I can see broadly two ways to achieve this:

1. Add a new variable like `BST_RUN_COMMANDS` to `Element()` class and use that to determine if the plugin supports it.
2. Define a new method like `shell()` that the plugins can choose whether or not to implement, and not implementing it would raise a nice error.

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior from doc/examples/first-project with `bst shell --build hello.bst`, then trace the `bst shell --build` entry point and the Element/plugin behavior described in the issue. Decide how unsupported `import` and `stack` shells are identified, and verify that they produce specific errors instead of the generic staged-artifact message.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.