0

I need to use the Anima command without having to write the entire path every time.
I cannot use animaConvertImage in on an internal file in a folder other than the one where the Anima commands are located. I'm using macOS in a mac with M1 processor. I tried using the .bashrc file, but to no avail, specifically:

-I added the following lines to the ~/.bashrc file in the following way:

gedit ~/.bashrc &

And added:

ANIMAHOME=~/Software/Anima/build

export PATH=$ANIMAHOME/bin:$PATH

export LD_LIBRARY_PATH=$ANIMAHOME/lib:$LD_LIBRARY_PATH

(I did it following a guide but i don't know how it should work; the Anima file included animaConvertImage are located in /Software/Anima/build/bin. )

Finally I saved and closed the terminal to make the changes active.

Then I used the command:

animaConvertImage -i dwi/Noddi_Combined_Tensors_final.nrrd -I

With dwi folder external to the Software folder I always get as output:

-bash: animaConvertImage: command not found

How can I solve the problem? (I'm not sure if the two are connected to each other since I'm a beginner)

In order to give you more information I ran the following commands:

$ ls -l ~/Software/Anima/build/bin/animaConvertImage
-rwxr-xr-x 1 lorenzomarta staff 3807134 14 Feb 16:07 /Users/lorenzomarta/Software/Anima/build/bin/animaConvertImage

and

$ ps -p $$
 PID TTY           TIME CMD
 3889 ttys000    0:00.08 -bash
terdon
  • 242,166
  • 1
    Are those really the lines you added? Do you really all those spaces? For example, is it really ANIMAHOME = ~ / Software / Anima / build or did you mean ANIMAHOME=~/Software/Anima/build? – terdon Feb 15 '22 at 10:32
  • Please [edit] your question and make sure you show us exactly what you put in the file. Use the formatting tools to format code as code for clarity. Next, tell us if you saved the file or just "closed the terminal" and, finally, show us the output of ls -l ~/Software/Anima/build/animaConvertImage. You seem to be expecting to find an executable file named animaConvertImage in the directory ~/Software/Anima/build/ and the output of the ls command will show us if it actually exists there or not. – terdon Feb 15 '22 at 10:53
  • 1
    Please *EDIT* your question to answer comments. As you can see, comments are very hard to read. Also, please tell us your operating system. Are you using macOS? What version? Are you using bash or zsh? ~/.bashrc is not really relevant to macOS since newer versions have switched to zsh instead of bash and even older versions which did use bash wouldn't read ~/.bashrc. – terdon Feb 15 '22 at 11:16
  • Please *[EDIT]* your question and add the output there so we can read it. And yes, you are using a mac machine, OK, but what operating system? Is it macOS or have you installed a Linux on it? Finally, please clarify what shell you are using. If you don't know, just [edit] your question and include the output of ps -p $$. – terdon Feb 15 '22 at 14:48
  • Thanks for your help, I hope the problem is clearer now – Lorenzo Marta Feb 15 '22 at 15:18
  • Excellent, thank you! One last test: try adding those exact lines you added to ~/.bashrc but add them to ~/.profile instead. Then open a new terminal and try running animaConvertImage again, does that work? – terdon Feb 15 '22 at 15:48
  • Same output: -bash: animaConvertImage: command not found – Lorenzo Marta Feb 15 '22 at 15:51
  • Do you have a file named ~/.bash_profile? What is the output of ls ~/.bash_profile? – terdon Feb 15 '22 at 15:52
  • The output is /Users/lorenzomarta/.bash_profile – Lorenzo Marta Feb 15 '22 at 15:54
  • Ah! OK, then undo the changes from ~/.profile and add them to ~/.bash_profile instead. Does that make it work? – terdon Feb 15 '22 at 15:55
  • You saved me!!! Thank you very much – Lorenzo Marta Feb 15 '22 at 16:00
  • great! I'll write up an answer explaining the details. – terdon Feb 15 '22 at 16:02

1 Answers1

0

There are two main categories of interactive bash (and others) shell: login and non-login shells. The main difference between the two is what files are read when the shell is launched, but please see the link above for details. Unlike most *nix systems, macOS will launch login shells by default. This is why you see -bash instead of bash in the output of ps -p $$.

Login shells do not read ~/.bashrc but instead read ~/.bash_profile (if present) or else ~/.profile (and some other files as well all of which are explained in the first link above). So the changes you made to ~/.bashrc were ignored because the shell you are running is a login shell.

So, instead of editing ~/.bashrc, you should edit ~/.bash_profile if that exists or, if it doesn't, edit ~/.profile. The lines are correct but you were simply editing the wrong file.

terdon
  • 242,166