Fatal: The command needs to be used from the top of the build tree

I keep hitting this annoying sfdk error from time to time:
Fatal: The command needs to be used from the top of the build tree (/home/attah/repos)
It appears (but only sometimes) with sub-commands like build-shell and prepare, and i really can’t understand why, because it makes them completely useless.

Today i hit it again a few times, but after having run sfdk build it started working all of a sudden.
What is going on? And could the error message perhaps include a hint on what to fix (if it even has to be this way)?

Please check sfdk build-init --help and also search for build-init in sfdk --help-building.

The reason that it suggests you to run it from /home/attah/repos is that you used it there before and it left its .sfdk directory there. You likely want to remove it. Nowadays, sfdk does not recklessly pollute random directories with its .sfdk directory anymore and instead fails with the annoying error :slight_smile:


Although… it would be nice if it was just less annoying, full stop.
Other build tools certainly have no qualms about writing to . so why should sfdk?

Leaving garbage behind is one issue. The other is that many sfdk commands are only valid when executed from the top of a build tree (because sfdk often wraps tools like rpmbuild to do the actual job in a context defined by RPM SPEC etc.), which was not obvious to all and led to builds broken strange ways. There are few other reasons out of which I will name just one more, that sfdk should also shout when you accidentally try to restart build with different build target - a feature we still miss and another source of hard to understand build errors.

Just for the record i still don’t understand this, and the error message would definitely benefit from having a hint included.