Copying from /usr/local/bin to /usr/bin?

  • Thread starter Thread starter CAF123
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on the challenges of moving the gfortran executable from /usr/local/bin to /usr/bin on a Mac. Users confirmed that root permissions are required for such operations and suggested alternatives like creating a symbolic link or modifying the PATH environment variable. The gfortran executable is identified as a Fortran 77 compiler, part of the GNU Compiler Collection (GCC), and users were advised to avoid moving executables within the /usr directory to prevent system issues. The recommended approach is to ensure /usr/local/bin is included in the PATH or to define an alias for gfortran.

PREREQUISITES
  • Understanding of UNIX file permissions and the sudo command
  • Familiarity with the terminal and command-line operations on macOS
  • Basic knowledge of environment variables, specifically PATH
  • Awareness of Fortran compilers, particularly gfortran and its role in the GNU Compiler Collection
NEXT STEPS
  • Learn how to create symbolic links in UNIX using the ln command
  • Research how to modify the PATH environment variable in macOS
  • Explore the installation process for Fortran compilers, including gfortran
  • Investigate the LoopTools installation requirements and troubleshooting steps
USEFUL FOR

This discussion is beneficial for macOS users, software developers, and anyone working with Fortran compilers, particularly those looking to configure and use LoopTools effectively.

  • #31
CAF123 said:
Thanks! Yes it was an older version that I had downloaded and hadn't realized. It now works :) I want to use this with mathematica, which has the simplest user interface. On page 29 (sect 1.6) it tells me to write Install["LoopTools"] after writing some path. Do you know what hosttype means?
Which directories do you have in the 'LoopTools' directory now?
There should be a new one that identifies your Mac somehow, and that's what the '(hosttype)' is.
 
Technology news on Phys.org
  • #32
Thanks! Yes there was a new one called x86_64-Darwin so I guess that is it. Then I typed in
set path=$path $HOME/LoopTools/x86_64-Darwin/bin as instructed. I tried to then run Install["LoopTools"] within mathematica but it didn't work. What does it mean by the tsch and .cshrc? (if I need to do something there)
 
  • #33
CAF123 said:
Thanks! Yes there was a new one called x86_64-Darwin so I guess that is it. Then I typed in
set path=$path $HOME/LoopTools/x86_64-Darwin/bin as instructed. I tried to then run Install["LoopTools"] within mathematica but it didn't work. What does it mean by the tsch and .cshrc? (if I need to do something there)
Is 'LoopTools' in your home directory?
Can you check with the following command?
Code:
ls -l $HOME/LoopTools/x86_64-Darwin/bin

The usual shell on a Mac is 'bash' instead of 'tcsh' if I'm not mistaken.
And the corresponding configuration file is $HOME/.bashrc instead of $HOME/.cshrc .
So I think we need to modify the .bashrc instead.

That means editing $HOME/.bashrc and adding the following line:
Code:
export PATH=$PATH:$HOME/LoopTools/x86_64-Darwin/bin
After that Mathematica has to pick up the changed path somehow.
That may require logging out and back in.
 
  • #34
I've got LoopTools-2.14 in Downloads folder and the bin folder within the hosttype is located in Macintosh HD/Users/myname/Downloads/LoopTools-2.14/x86_64-Darwin/bin so maybe the beginning of that replaces HOME but not sure.

Oh I didn't get what you meant by modifying the .bashrc command. I wish these user manuals would be more noob friendly hehe
Thanks for your patience!
 
  • #35
Sure. No problem.
These unix tools tend indeed to require a certain level of unix command line knowledge.
What do you get after the following command?
Code:
ls -lA $HOME
Please leave out anything that is personal.
 
  • #36
Thanks, I get the following
Code:
.CFUserTextEncoding
.DS_Store
.Trash
.bash_history
.bash_profile
.bash_profile~
.bash_sessions
.config
.cshrc
.dropbox
.emacs.d
.kshrc
.profile
.ssh
.subversion
.vim
.viminfo
Desktop
Documents
Downloads
Dropbox
Library
Movies
Music
Pictures
Public
plus other personal files. I've tried to write export PATH="/Users/myname/Downloads/LoopTools-2.14/x86_64-Darwin/bin:$PATH" in the file .bash_profile but still I can't get the Install["LoopTools"] to run.

Thanks!
 
  • #37
Can you check which executable files there are in that x86_64-Darwin/bin directory?
And then type:
Code:
which whatever-executable-file-without-path
Then try again with:
Code:
tcsh
which whatever-executable-file-without-path
 
  • #38
I like Serena said:
Can you check which executable files there are in that x86_64-Darwin/bin directory?
There is a LoopTools executable, fcc one and lt one.
And then type:
Code:
which whatever-executable-file-without-path
OK, does this just tell me the path to the executable files?
Then try again with:
Code:
tcsh
which whatever-executable-file-without-path
This came with an error saying LoopTools: command not found
 
  • #39
CAF123 said:
There is a LoopTools executable, fcc one and lt one.
OK, does this just tell me the path to the executable files?

This came with an error saying LoopTools: command not found
Yes. It means your terminal can find the executable.

Okay. Let's try editing your .cshrc and add the line:
Code:
set path=($path $HOME/Downloads/LoopTools-2.14/x86_64-Darwin/bin)
and try again.
If it works, please log out and back in before starting Mathematica.
 
  • #40
So do you mean to say just write in the line
Code:
set path=$path $HOME/Downloads/LoopTools-2.14/x86_64-Darwin/bin
in the terminal? (The brackets you had seem to give me an error but when taking them out it seems to work)
I logged out and back in but mathematica still says it can't find the MathLink executable (same error as before)
 
  • #41
CAF123 said:
So do you mean to say just write in the line
Code:
set path=$path $HOME/Downloads/LoopTools-2.14/x86_64-Darwin/bin
in the terminal? (The brackets you had seem to give me an error but when taking them out it seems to work)
I logged out and back in but mathematica still says it can't find the MathLink executable (same error as before)
No, it should be added to the file /Users/yourname/.cshrc, and I believe it should include the parentheses.
Just to check that it is correct can you execute:
Code:
tcsh
set path=($path $HOME/Downloads/LoopTools-2.14/x86_64-Darwin/bin)
which LoopTools
 
Last edited:
  • #42
Ah I see, ok I added that line to the file .cshrc and then executed the three lines above. Nothing happened but I guess that was to be expected. So, I think it is ok. I logged out but mathematica still gives the same error.

Edit: Could I not try writing the same thing in .bash_profile? But indeed I see that the manual suggests .cshrc

Just going for some food now, but thanks a lot for your help so far!
 
  • #43
CAF123 said:
Edit: Could I not try writing the same thing in .bash_profile? But indeed I see that the manual suggests .cshrc

Which file to use depends on whether you're using the Bash shell (.bash_profile) or the C shell (.cshrc).
 
  • #44
I like Serena said:
The usual shell on a Mac is 'bash' instead of 'tcsh' if I'm not mistaken.
And the corresponding configuration file is $HOME/.bashrc instead of $HOME/.cshrc .
So I think we need to modify the .bashrc instead.
I had to look up the difference between .bashrc and .bash_profile (which is what I use).

From here: https://apple.stackexchange.com/que...he-difference-between-bash-profile-and-bashrc
When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

But, if you’ve already logged into your machine and open a new terminal window (xterm) then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

On OS X, Terminal by default runs a login shell every time, so this is a little different to most other systems, but you can configure that in the preferences.
 
  • Like
Likes   Reactions: I like Serena
  • #45
CAF123 said:
Ah I see, ok I added that line to the file .cshrc and then executed the three lines above. Nothing happened but I guess that was to be expected. So, I think it is ok. I logged out but mathematica still gives the same error.
Edit: Could I not try writing the same thing in .bash_profile? But indeed I see that the manual suggests .cshrc
No, unfortunately it's not okay that nothing happened. 'which LoopTools' should either print the path to it, or give an error that it cannot find it.
So I'm currently at a loss why this doesn't happen.

Btw, be careful how you add the line with the PATH.
.bash_profile and .cshrc are incompatible, and completely independent from each other.

How do you start Mathematica exactly?
Can you start it from within the terminal?
Is it a tcsh script? Or something else?

CAF123 said:
Just going for some food now, but thanks a lot for your help so far!
I can understand. ;)
 
Last edited:
  • #46
Hi again :)
I like Serena said:
No, unfortunately it's not okay that nothing happened. 'which LoopTools' should either print the path to it, or give an error that it cannot find it.
So I'm currently at a loss why this doesn't happen.
Ah sorry, I realized I misinformed you yesterday that nothing happened - when I typed in which LoopTools indeed I got the path to it.

Btw, be careful how you add the line with the PATH.
.bash_profile and .cshrc are incompatible, and completely independent from each other.
I see, so if I add the same path in both files then this leads to problems?

How do you start Mathematica exactly?
Can you start it from within the terminal?

I just opened up mathematica from finder and done it within a mathematica notebook. I don't think I've opened mathematica up using the terminal before. Since we've followed all the instructions given in the manual perhaps the way I'm starting mathematica is incorrect - somehow it doesn't know about the addition of the new path perhaps.
 

Similar threads

Replies
10
Views
2K
Replies
16
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 14 ·
Replies
14
Views
7K