FS#71639 - [root] unclear error when attempting to run thisroot.sh

Attached to Project: Community Packages
Opened by valentin v (vavolkl) - Wednesday, 28 July 2021, 11:33 GMT
Last edited by Konstantin Gizdov (kgizdov) - Friday, 26 November 2021, 12:51 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Konstantin Gizdov (kgizdov)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

The patched thisroot.* should have a clearer error message (when this file is sourced from another scripts the error message says something like "ERROR: bash should never be used") and actually only print a warning and not fail with an error, in order to work with scripts like this_dd4hep.sh


Steps to reproduce:

Running the tests of DD4hep.
This task depends upon

Closed by  Konstantin Gizdov (kgizdov)
Friday, 26 November 2021, 12:51 GMT
Reason for closing:  Fixed
Comment by Konstantin Gizdov (kgizdov) - Friday, 30 July 2021, 11:30 GMT
I am not familiar with the DD4hep tests or how to run them. I was also not able to reproduce your error. When I try to directly run thisroot.{csh,sh,fish} or even when I try to source it, it always gives me the following message "ERROR: thisroot.{csh,sh,fish} should never be user". Which to me is self-explanatory - do not use thisroot.{csh,sh,fish} to configure ROOT.
Comment by valentin v (vavolkl) - Thursday, 14 October 2021, 22:07 GMT
  • Field changed: Percent Complete (100% → 0%)
Apologies if I was not clear. The message is fine when directly sourcing thisroot.sh.

But create a file "test.sh" with these two lines:

source /usr/bin/thisroot.sh
echo "do something with root ..."

and then run "source test.sh" - You'll see something like:

k4-arch-01: ~$ source test.sh
basename: invalid option -- 'b'
Try 'basename --help' for more information.
ERROR: should never be used!
Connection to k4-arch-01 closed.

depending on how the script is called, basename may print all kinds of things, none of them self-explanatory. A very easy fix that might save others hours of debugging is to just explicitly print:

fail "ERROR: thisroot.{sh,sh,fish} should never be used!" 1

instead of dealing with all the ways that basename can fail.

For the second part of the issue, consider that many people may have written scripts that use thisroot.* with the arch installation it is not necessary, which is great, but using fail means breaking all those scripts. Why not print a warning and make sourcing thisroot.* a noop?

Comment by Konstantin Gizdov (kgizdov) - Saturday, 16 October 2021, 15:59 GMT
Would the attached script do the job?
Comment by valentin v (vavolkl) - Sunday, 17 October 2021, 13:09 GMT
That looks great, thank you very much!
Comment by Konstantin Gizdov (kgizdov) - Friday, 12 November 2021, 00:29 GMT
this should ship in [community-testing]/root 6.24.06-5

Loading...