I'm wondering whether someone couald tell me how to add Octave to PATH environment variable in Mac Sierra?
I need to make available octave under terminal from any folder.
I have installed my last version of octave in my machine but... what's now?
Thanks in advance for your help
You can modify your ~/.bash_profile file and add your Octave installation folder (note that yours may be different than mine) to the PATH environment variable.
~/.bash_profile
export PATH="$PATH:/usr/local/octave/4.2.0/bin"
Note that this modified PATH environment variable will only be available from the terminal (not GUI apps).
Related
I've heard that it's best to wait after a new OS comes out until a few updates come in so that the build is a bit more stable. However, I'm also wondering if I will have to set up my environment, PATH, etc again after upgrading. Will updating change anything or will everything be the same as before?
(I'm currently on macOS Mojave 10.14.6)
One thing to note is that environment variables can live in different places, so it may depend on which ones you're referring to.
Usually if Mac OS upgrades need to change a file that you're likely to customize, like the httpd.conf file, they'll make a backup first. But there's no guarantee; it's good to keep a Time Machine backup handy from before you upgrade. With that you can copy in anything that got lost.
Also note that Catalina is switching the default shell from bash to zsh, so if you have environment variables in .bash_profile or .bashrc, those will be ignored. You can switch back to bash if you want, or configure zsh with similar settings.
Starting with macOS Catalina -- by default it takes zsh and hence you need to change in zprofile. Please follow below steps
touch ~/.zprofile; (// This will create the profile)
open ~/.zprofile; (Open this in an editor)
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.11.jdk/Contents/Home
export GRADLE_HOME=/Users/myuser/Documents/installs/gradle-6.8.3
export PATH=$PATH:/Users/myuser/Documents/installs/gradle-6.8.3/bin
source ~/.zprofile (Execute the new .zprofile by either restarting the terminal window or using this)
I use mac and rubymine 7.1.2 and I want to setup default environment variables? Is it possible to setup them up per run configuration so every test, rails generator, rails console has access to them.
Is there something like .env file or something else, so it's possible just set them once?
Jetbrains actually has a page to help you do just this:
Mac OS X applies .bash_profile and .profile only for Terminal.app environment and Apple's technical documentation suggests using ~/.MacOSX/environment.plist for other applications. So, by default PATH value will differ for RubyMine and the console.
MacOS 10.6 or later
We recommend to manage your environment variables using free
Enviroment Variables preference pane instead of environment.plist
manual editing.
MacOS < 10.6
Unfortunately, the "environment.plist" approach doesn't always work on
MacOS < 10.6, e.g if you start RubyMine from Spotlight the environment
is not applied.
Thus real solution is to set your environment variables in
/etc/launchd.conf (thanks to David Goudreau for this tip). For
detailed description please read Mac OS X Global Environment Variables
article.
So you should:
Open /etc/launchd.conf file (e.g. $sudo nano /etc/launchd.conf)
Then set correct PATH env variable
setenv PATH /Users/romeo/.gem/ruby/1.8/bin:/opt/local/bin:/opt/local/sbin:/opt/local/libexec/git-core:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Set other env variables for RubyMine if necessary
Save changes
Reboot
P.S: If you always launch RubyMine using Dock or QuickSilver and do
not use Spotlight you can install Enviroment Variables preference pane
and use it instead of the manual environment.plist editing.
NB: Please don't miss "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
in the end of PATH value, because PATH=...:$PATH doesn't work here.
I'm wondering how PATH variable is set by Mac Installers on Mac OSX.
For example:
Look at golang Mac OSX Installer. From the link https://golang.org/doc/install:
Mac OS X package installer
Download the package file, open it, and follow the prompts to install
the Go tools. The package installs the Go distribution to
/usr/local/go.
The package should put the /usr/local/go/bin directory in your PATH
environment variable. You may need to restart any open Terminal
sessions for the change to take effect.
So, the I can see /usr/local/go/bin in $PATH but it's not being set in .profile, .bashrc or launchd.conf.
Can anybody please help me to understand?
There are a couple methods of setting environment variables in Mac OS X (lots of discussion here). In the case the Go package, it is adding a file in /etc/paths.d named go that contains /usr/local/go/bin. Here's an answer to another question explaining that a utility called path_helper is being launched and it's inspecting the /etc/paths.d directory.
You can verify this yourself by using an application called Pacifist to inspect the contents of the Go package and looking at the files it's installing.
I installed Python 2.7.3 on my Windows 7 computer using the binary, the first link. After installing it, IDLE works but nothing else recognizes Python. For example, typing python at the command prompt returns the message "'Python is not recognized as an internal or external command, operable program or bath file."
Following this post, I made sure that python 2.7 was in the PYTHONPATH environment variable. However, that didn't help.
What should I do?
PYTHONPATH system variable is used by Python itself to find directories with installed packages.
PATH system variable is used by OS (particularly Windows) to find executables which can open certain files like *.py scripts.
So, you need to add directory with python.exe (for example C:\Python27) to PATH system (or user) variable and not to PYTHONPATH. It can be done the same way as described in the link you've found in the same tool window.
For example on my machine PATH system variable is set to C:\Python27;C:\MinGW\bin;...
Like Vladimir commented, for setting up python in windows, you need to add the directory where your python.exe is located (for example C:\Python27) to PATH
You can confirm if python is in your environment variables by looking at the output of echo %path%
Keep in mind that after editing the PATH variable using the control panel, you have to open a new terminal, as the setting will NOT be updated in existing terminals.
Another possibility is that you added the wrong path to the PATH variable. Verify it.
The bottom line is, if the directory of your python.exe is really in PATH, then running python will really work.
Here are your steps:
Right-click Computer and select Properties.
In the dialog box, select Advanced System Settings.
In the next dialog, select Environment Variables. In the User Variables section, edit the PATH statement to include this:
C:\Python27;C:\Python27\Lib\site-packages\;C:\Python27\Scripts\;
Now, you can open a command prompt (Start Menu|Accessories or Start Menu|Run|cmd) and type:
C:\> python
That will load the Python interpreter!
You can install for single user rather than choosing the option of "Install for all users". I was facing the same issue, but when I tried installing just for myself, I was able to install successfully.
It looks like xcode's $PATH environment setting is different from my user shell environment.
Where does xcode get the $PATH setting from and what's the best way to append to the search path?
if you're writing a Run Shell Script build phase, you can just do:
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
There's some confusion in these answers, as some of them are trying to solve the $PATH for the built executable being run by Xcode. But the question is about Xcode, implying that it's about the build process itself.
For example, in a Build Phase Run Script step that runs an executable installed by Homebrew. It's not a good idea to hard-code the build process to include a path that is specific to one build machine (New macOS versions come out, new developers join the team, etc.)
The problem has multiple layers:
Changing $PATH in bashrc/zshrc/profile takes effect on shell sessions, but not in macOS applications
To solve this, you can set the PATH for applications using:
sudo launchctl config user path $PATH
You will then need to restart your machine for the change to take effect. You will need to run this again if you change your $PATH.
(This came from a comment on GitHub.)
Xcode by default does not use the system $PATH, and replaces it with its own sanitized value
This is solved by changing a User Default. This probably has some risk, since Xcode does this sanitization to ensure that its own build tools are used, and if you have executables with the same name in other places, they might be run instead. Caveat emptor!
defaults write com.apple.dt.Xcode UseSanitizedBuildSystemEnvironment -bool NO
And it looks like this gets reset on every restart of macOS, so be prepared to issue this command every time you restart.
(This part came from this answer.)
The easiest solution is to add the PATH variable in Xcode.
PATH=${PATH}:/usr/local/bin
This applies for OSX 10.7 and earlier ONLY.
XCode gets its environment variables the same way as other OS X processes, from ~/.MacOSX/environment.plist.
Check developer.apple.com/qa/qa2001/qa1067.html for details on how to set things.
In Xcode 5 you can add your PATH as a variable to either a target or the project settings.
Add a custom variable with the +sign on the top of the page
Edit the name of the variable to be PATH and add your preferred value (e.g. /usr/local/bin for a default install of homebrew.
If you are talking specifically about the executable search path environment variable named PATH, then there are a few places that it is set:
In your shell settings if it is a command line tool. Depending on your shell, this could be ~/.cshrc, ~/.profile, ~/.bash_profile, etc.
In the environment.plist file that was mentioned earlier.
If you are in a debugger, then it is whatever gdb uses. I believe that gdb will read commands from ~/.gdbinit if it exists.
XCode lets you set environment variables within the Info page for executables.
This is an update for later versions of macOS and Xcode as things have altered. This is with Xcode 11.0 and macOS 10.14
The biggest issue is that ~/.MacOSX/environment.plist does not get read now.
Build Settings
This means that if in the build you need the PATH set, e.g. for external builds and they run executables there is no simple solution. /etc/paths does not seem to be read either.
The solution is as in #GhostLyrics answer to add the PATH variable in Build Settings. However as noted in comments Xcode will not just use that value but it puts its own values before that. Also it does a straight textual substitution and so you need to also add the separator that PATH uses i.e. the : (colon). The value I have added is :opt/local/bin I also found that you can only do this for a target and not at the project level.
Run Shell Script
This is the simple case as in this answer
PATH=${PATH}:/opt/local/bin
or whatever inside the script content.
Alternatively put this change in your non login shell starter file e.g. ~/.bashrc ~/.zshrc
Running the executable
This is done in the Schema in the Run portion.
Set PATH in the environment variables as stated in answers here. Note I have not tried this and I am not certain how much of the PATH needs setting.
Xcode doesn't look at your shell path environment.
Have a look at NSProcessInfo; and do an NSLog to see what comes up.
If you want a path to apply to all graphical programs you need to set up the ~/.MacOSX/environment.plist. as described.
The recommended way to set the environmen variables are actually in /etc/paths and etc/paths.d although these are also not picked up by Xcode.
I asked about this here.
Nothing was working for me in XCode 7.
You need to set the PATH variable in XCode schemes.
Found the solution at:
Where to set environment variables for app?
Try opening your xcode project from the terminal, this worked for me: open some.xcodeproj
Instead of opening xcode and then loading the project or double clicking on it.
I know... silly