Menu

#67 Cannot debug scripts called without their full path despite being in the PATH

v1.0_(example)
open
nobody
None
5
2021-11-15
2020-08-08
No

Ubuntu focal 20.04
bashdb 5.0-1.1.12

$ which script_a.sh
/path/to/script_a.sh

$ bashdb script_a.sh
bash debugger, bashdb, release 5.0-1.1.2
...
bashdb: cannot read program to debug: script_a.sh.

$ bash bashdb script_a.sh
bash debugger, bashdb, release 5.0-1.1.2
...
bashdb: cannot read program to debug: script_a.sh.

We could specify the whole script path during the call, but we cannot when a nested script script_b.sh is called within the first script_a.sh:
script_a.sh

1
2
#!/bin/bash
script_b.sh $parameter1 $parameter2

Interestingly, if we step over script_b.sh during the debugging procdess, that script is called & found.
However, if we try to step into it with debug, we get:

bashdb<3> debug
Debugging new script with /bin/bash /usr/bin/bashdb -q -L /usr/share/bashdb script_b.sh <parameter1> <parameter2>
bashdb: cannot read program to debug: script_b.sh.

Discussion

  • Garry Madrone

    Garry Madrone - 2020-08-12

    Hi, it doesn't look like anyone is monitoring the bug reports or support issues here. I would like to get to the point you are, but I'm unable to install bashdb 5.0 using the install instructions I found in the bashdb-code directory. What procedure did you use to install bashdb? Thanks.

     
  • DiagonalArg

    DiagonalArg - 2021-11-15

    @jcmanicot - Thanks for that PPA. Note that the Ubuntu bashdb package is missing, so instead I'll use Bullseye for Ubuntu 20.04.

    Edit: I was having trouble with your Debian packages when downloading with curl, but then discovered that the links have to be selected in the browser, and then select >> "plain" to download.

     

    Last edit: DiagonalArg 2021-11-15
  • DiagonalArg

    DiagonalArg - 2021-11-15
    Post awaiting moderation.
  • Rocky Bernstein

    Rocky Bernstein - 2021-11-15

    I think what is going on is who is supposed to resolve the full path of the script. I believe if you install bashdb as a command rather than run it as a script to thebash command, then things are fine because the your shell resolves this so that the bashdb program doesn't.

    As bash is currently distributed, there is no builtin bash function whence or which command. So far as I know, so bashdb would have to do this resolution, and I am not sure I'd want to add that. I suppose it could try running whence or which inside bashdb, but there is no guarantee either of those would work.

    bashdb I believe needs to know about the directory that the script is in so that it can set cwd properly and that too I think is something a shell does.

    I could be wrong here, but that's my current thinking.

     
  • DiagonalArg

    DiagonalArg - 2021-11-15

    @jcmanicot - I've emailed you directly, but for anyone else ... There is an error in the postinst script in the .deb package in his Debian repos. a ln -sfv /usr/share/bin/bashdb is being created to /bin/bashdb. For one thing, /usr/share/bin/bashdb does not exist. I think this should be /usr/bin/bashdb. Secondly, in Ubuntu, /bin is simlinked to /usr/bin. The effect is to wipe out bashdb altogether. The solution I found was to extract the deb (ar x <file>.deb) and copy usr/bin/bashdb into place.

     
  • Jean-christophe Manciot

    @DiagonalArg
    Are you aware that each bashdb version/tag matches a bash version?
    The first post of this thread was written more than 1 year ago for Ubuntu focal when there was a bashdb tag matching a relevant bash version.
    Since then, Ubuntu has moved on to impish and so has my PPA which targets only the latest Ubuntu distribution.
    For the latter, bash version is 5.1.3 and bashdb is not compatible with that release.
    That's the reasons why you couldn't find any bashdb package on https://git.sdxlive.com/PPA/tree/Ubuntu/pool/stable/b.

    The same reasons apply to the DR (https://git.sdxlive.com/DR/tree/Debian/pool/stable/b/bashdb) except that the latest stable bullseye distribution has only recently been upgraded to a new development release which I consider not stable enough to be used.
    I'll investigate your comment regarding the old bashdb package available in this DR but keep in mind that it was designed for bash 5.0 on Debian bullseye.

     

    Last edit: Jean-christophe Manciot 2021-11-15
  • Jean-christophe Manciot

    @DiagonalArg
    Regarding your remark about the postinst, it is a leftover from older bashdb versions and it should have been removed. You're right, It prevents a correct installation of bashdb on bullseye.

    A new release has been posted without the postinst to allow a correct installation.
    You need to install a compatible bash version first with:

    # wget https://git.sdxlive.com/DR/plain/Debian/pool/stable/b/bash/bash_5.0-4+11.0_amd64.deb
    # dpkg -i bash_5.0-4+11.0_amd64.deb
    # apt-mark hold bash
    

    You can grab the new bashdb and install it with:

    # wget https://git.sdxlive.com/DR/plain/Debian/pool/stable/b/bashdb/bashdb_5.0-4.1.12-11.0_amd64.deb
    # dpkg -i bashdb_5.0-4.1.12-11.0_amd64.deb
    

    However, this does not solve the original issue "Cannot debug scripts called without their full path despite being in the PATH".

     

    Last edit: Jean-christophe Manciot 2021-11-15
  • DiagonalArg

    DiagonalArg - 2021-11-15

    @jcmanciot -

    Are you aware that each bashdb version/tag matches a bash version?

    I did not know that. Thanks for clarifying. Is the sub-version relevant, too? Ubuntu 20.04 is right now on bash version 5.0.17, and I have installed bashdb_5.0-1.1.12-11.0.

     

Log in to post a comment.