1

I have this issue with bash on a MacBook Pro (chip M1, OS: 12.5.1). It's been there since day 1.

  • I set bash as the default shell in Terminal>Preferences>General enter image description here
  • I create and modify a new .bash_profile file in my ~ folder using vi so I can exclude line-ending issues, formatting issues due to the editor, and such

  • Most of the commands I write in the .bash_profile file do not work. For example, echo seems to work; source returns "No such file or directory" even when the file actually exists and the path is correct; ls and many others give "Command not found". All those commands run in the terminal with no problems at all

  • the PATH variable seems okay. export doesn't return an error message. Without appending new paths in .bash_profile, I have /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin, which is what I expect looking into /etc/paths.d/

  • for example, the line export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH" to .bash_profile doesn't produce any error when sourcing the file; the line source "/Volumes/Macintosh\ HD/Applications/root_v6.26.06/bin/thisroot.sh" (file, path verified) gives No such file or directory

  • the /etc/paths file is still untouched:

    /usr/local/bin
    /usr/bin
    /bin
    /usr/sbin
    /sbin

  • probably part of the same problem, the terminal overwrites the lines that are longer than the window length

  • among the attempts to solve the problem, I updated bash to a more recent version, 5.1.0; bash --version responds accordingly. Same errors.

  • the issue was there with previous OS versions as well. Updating didn't help

Hopefully, someone who ran into the same issues can share some good hints. Thanks!

8
  • 2
    Welcome to Ask Different. It looks like there's a problem with PATH: move the export PATH line to the top of .bashrc, otherwise bash won't know where to search for commands. As for the "No such file or directory" error when running source, either escape spaces with backslash notation (source /Volumes/Macintosh\ HD/Applications/root_v6.26.06/bin/thisroot.sh), or with double quotes (source "/Volumes/Macintosh HD/Applications/root_v6.26.06/bin/thisroot.sh"), but don't use both.
    – jaume
    Commented Oct 6, 2022 at 7:43
  • If the comment from @jaume doesn't solve your problem, please add your .bashrc to the question.
    – nohillside
    Commented Oct 6, 2022 at 9:37
  • export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH should not be needed, these directories are already in PATH (based on the content in /etc/paths). /etc/paths is static, not sure why you mention this in the question at all.
    – nohillside
    Commented Oct 6, 2022 at 9:39
  • Hello, thank you all for your replies! - Having either quotes or backslashes in the source lines actually solves the problem. Nice spot @jaume! - Moving the PATH definition line to the top didn't change things - All other commands in the file are now correctly executed - Lines are no longer overwritten - No differences between .bash_profile and .bashrc - for a correctly working system, the export PATH line is not needed - I agree with @nohillside. Here, it could have helped to understand - Root is still not correctly sourced, but I think this doesn't belong here
    – matt
    Commented Oct 6, 2022 at 10:48
  • With this configuration, I would have expected that .bash_profile does not get sourced at all, when you open a new terminal tab. This file is only processed for interactive login shells. Could it be that you explicitly source it from somewhere (for instance, from .bahshrc)? Commented Oct 10, 2022 at 8:06

1 Answer 1

2

Thank you all for your replies! I think the problem is now solved

  • Having either quotes or backslashes in the source lines actually solves the problem. Nice spot @jaume!
  • Moving the PATH definition line to the top didn't change things
  • All other commands in the file are now correctly executed
  • Lines are no longer overwritten
  • No differences between .bash_profile and .bashrc
  • For a correctly working system, the export PATH line is not needed - I agree with @nohillside. Here, it could have helped to understand
  • Root is still not correctly sourced, but I think this doesn't belong here
5
  • 1
    Not sure I understand the last point.
    – nohillside
    Commented Oct 6, 2022 at 10:54
  • 1
    Root is the name of a data analysis tool, root.cern. I am having troubles with the installation
    – matt
    Commented Oct 6, 2022 at 10:58
  • Glad you have resolved it. I'm curious, what changes have you made so that commands are now executed?
    – jaume
    Commented Oct 6, 2022 at 11:03
  • 1
    It only was having the backslash inside the quotes. I understand that having a single syntax error invalidates the whole file, no matter the position of the mistaken line...
    – matt
    Commented Oct 6, 2022 at 11:17
  • 1
    The installation is also now solved. The residual issue was root-config: command not found, with the file present in the correct directory. Workaround: cd /Volumes/Macintosh\ HD/Applications/root_v6.26.06/bin/; source thisroot.sh; cd in .bash_profile
    – matt
    Commented Oct 6, 2022 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .