How does installers set PATH variable on Mac OSX? - macos

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.

Related

How to add Octave to PATH environment variable in Mac Sierra?

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).

How to compile a Go package on Windows?

The documentation is all for Mac OS X and Linux, and I wish to know how to compile a Go package on the Windows platform. On Windows, I do not know how to write the make file and which tool to use to make it.
It seems that there is not a tool named make or go make to use with the installation file of Go development tools.
Compiling a Go package on Windows is like compiling a Go package on Linux or Mac OS X. Use the go build command. There is no make file.
Here are some instructions.
Getting Started
How to Write Go Code
Compile packages and dependencies
There are no more Makefiles needed in Go, so the make tool isn't necessary. You also do not need cygwin.
If you do not seem to have a valid go command in your windows shell, then try following the official docs on installing Go for windows
Zip archive
Extract the zip file to the directory of your choice (we suggest
c:\Go).
If you chose a directory other than c:\Go, you must set the GOROOT
environment variable to your chosen path.
Add the bin subdirectory of your Go root (for example, c:\Go\bin) to
to your PATH environment variable.
MSI installer (experimental)
Open the MSI file and follow the prompts to install the Go tools. By
default, the installer puts the Go distribution in c:\Go.
The installer should put the c:\Go\bin directory in your PATH
environment variable. You may need to restart any open command prompts
for the change to take effect.
Setting environment variables under Windows
Under Windows, you may set environment variables through the
"Environment Variables" button on the "Advanced" tab of the "System"
control panel. Some versions of Windows provide this control panel
through the "Advanced System Settings" option inside the "System"
control panel.
The last section is important. Your windows PATH environment variable needs to have C:\Go\bin, so that you will have go in your path.
from: Golang windows, a complete setup guide, http://noypi-linux.blogspot.com/2014/07/golang-windows-complete-setup-guide.html
1) download ZIP
Get the latest code from: http://golang.org/dl/
2) extract ZIP
Extract zip to example C:\local\dev\go
3) create a gopath directory,
Gopath is where third parties will be stored. Example if you will
execute a "go get github.com/somelib", this library will be stored in
gopath. Create a c:\local\dev\gopath
4) set the environmental variables
open System Properties->Advanced->Environmental Variables
GOROOT=C:\local\dev\go
GOBIN=%GOROOT%\bin
GOPATH=c:\local\dev\gopath
5) add your gobin to PATH
append C:\local\dev\go\bin to PATH
6) test
6.1) create the path "C:\local\dev\gopath\src\myfirstproject"
6.2) create the main.go file "C:\local\dev\gopath\src\myfirstproject\main.go"
package main
import "fmt"
func main() {
fmt.Println("Hi foobar")
}
6.2) you can now build the project anywhere example,
6.2.1) open cmd.exe
6.2.2) cd c:\temp
6.2.3) go build myfirstproject
6.2.4) run myfirstproject.exe
7) get a few libraries
7.1) you can download some free git, svn, and hg for windows
7.2) once you have them you can now do "go get -u github.com/somelib"
8) get an IDE
download liteide
congrats!

'make' command missing from OS X

The make command is missing on my mac, running OS X version 10.6 (Snow Leopard). What should I do to install make?
You'll need to install the OS X developer tools from the Mac OS X installation discs.
EDIT: Directions here.
You need to install XCode, which comes along with make. You can download the latest XCode for free (if you're on Lion or Mountain Lion) from the Mac App store.
Update
It seems the link in the selected answer is a better solution, in that you don't have to add it to your path, it installs it in /usr/bin. I was originally thrown off by this as the answer mentions installation disks, which do not exist anymore (and are not needed here).
Original Post
make went missing on my installation of OSX Lion, even with XCode installed.
What I discovered was that, it was not in /usr/bin, but was in /Developer/usr/bin, which is not in $PATH environment variable by default. This is most likely a result of the XCode install.
You have a few options:
install it to one of the directories that is in your path
make a symbolic link to point to the Developer bin directory (for example, from /usr/bin)
modify your path to include the Developer directory (what I did) - see below
Add the developer bin to your path:
Somewhere in ~/.bashrc place the following code:
export PATH=$PATH:/Developer/usr/bin
#Remove Duplicates:
PATH=`perl -e '#A=split(/:/,$ENV{PATH});%H=map {$A[$#A-$_]=>$#A-$_} (0..$#A);#A=join(":",sort{$H{$a} <=> $H{$b} }keys %H);print "#A"'`
export PATH
Line 1: add /Developer/usr/bin to the end of the current path so it has low priority
Line 3: because we're adjusting path, we want to remove duplicates (in case you source more than once). Duplicates aren't really problematic, but this should cause the same directory to not be searched more than once, which may make it faster.
Line 4: Make it available to your environment
Note:
If you're using a different shell (for instance csh), you'll have to adjust the script above and make the changes in that corresponding resource file (~/.cshrc).
To apply changes you'll have to source ~/.bashrc or reopen your terminal.

Installer for a simple Mac OS command-line tool?

How can I build a novice-usable (clickable download) installer for a Mac OS X command-line tool, and where should the binary be installed so that a novice user with no knowledge of shell paths can just open the Terminal app and type "foo" to run the freshly installed foo tool?
Can the installer also install documentation so that the user can type "man foo"?
Are there any other options that should be considered to make the use of a pure command-line (stdin, stdout) tool accessible to a novice Mac user?
What's the minimum version of OS X you're targeting? 10.6 (and IIRC 10.5) include /usr/local/bin in the default PATH, but 10.4 did not. As long as you don't need to support 10.4, you should just put the executable in /usr/local/bin and the man page in /usr/local/share/man/man1 (or whatever the appropriate chapter number is).
For building the installer itself, you can use Apple's PackageMaker utility (part of Xcode). Create a prototype local folder with bin and share/man/man1 subfolders and populate them with your files. Create a package project in PackageMaker, and choose your organization name and minimum target OS. Drag the prototype folder into the project's Contents sidebar. Set the Destination to /usr/local. Switch to the Contents tab and edit the ownership and permissions the files should be installed with (the owner/group should probably all be root/admin, with rwxrwxr-x perms on the folders and executable, rw-rw-r-- on the man page). If any irrelevant files (e.g. .DS_Store) snuck in, exclude them. Look around for any other settings you want to change, then save the project and build the installer. Then test it, to make sure it does what you expect.

How to install pkg config in windows?

I am trying to do it, but all I can get is some source code that I don't know how to do deal with I downloaded from http://pkgconfig.freedesktop.org/releases/.
This is a step-by-step procedure to get pkg-config working on Windows, based on my experience, using the info from Oliver Zendel's comment.
I assume here that MinGW was installed to C:\MinGW. There were multiple versions of the packages available, and in each case I just downloaded the latest version.
go to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
download the file pkg-config_0.26-1_win32.zip
extract the file bin/pkg-config.exe to C:\MinGW\bin
download the file gettext-runtime_0.18.1.1-2_win32.zip
extract the file bin/intl.dll to C:\MinGW\bin
go to http://ftp.gnome.org/pub/gnome/binaries/win32/glib/2.28
download the file glib_2.28.8-1_win32.zip
extract the file bin/libglib-2.0-0.dll to C:\MinGW\bin
Now CMake will be able to use pkg-config if it is configured to use MinGW.
Get the precompiled binaries from http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
Download pkg-config and its depend libraries :
pkg-config_0.26-1_win32.zip
glib_2.28.8-1_win32.zip
gettext-runtime_0.18.1.1-2_win32.zip
A alternative without glib dependency is pkg-config-lite.
Extract pkg-config.exe from the archive and put it in your path.
Nowdays this package is available using chocolatey, then it could be installed with
choco install pkgconfiglite
I did this by installing Cygwin64 from this link https://www.cygwin.com/
Then - View Full, Search gcc and scroll down to find pkg-config.
Click on icon to select latest version.
This worked for me well.
I would like to extend the answer of #dzintars about the Cygwin version of pkg-config in that focus how should one use it properly with CMake, because I see various comments about CMake in this topic.
I have experienced many troubles with CMake + Cygwin's pkg-config and I want to share my experience how to avoid them.
1. The symlink C:/Cygwin64/bin/pkg-config -> pkgconf.exe does not work in Windows console.
It is not a native Windows .lnk symlink and it won't be callable in Windows console cmd.exe even if you add ".;" to your %PATHEXT% (see https://www.mail-archive.com/cygwin#cygwin.com/msg104088.html).
It won't work from CMake, because CMake calls pkg-config with the method execute_process() (FindPkgConfig.cmake) which opens a new cmd.exe.
Solution: Add -DPKG_CONFIG_EXECUTABLE=C:/Cygwin64/bin/pkgconf.exe to the CMake command line (or set it in CMakeLists.txt).
2. Cygwin's pkg-config recognizes only Cygwin paths in PKG_CONFIG_PATH (no Windows paths).
For example, on my system the .pc files are located in C:\Cygwin64\usr\x86_64-w64-mingw32\sys-root\mingw\lib\pkgconfig. The following three paths are valid, but only path C works in PKG_CONFIG_PATH:
A) c:/Cygwin64/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
B) /c/cygdrive/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig -
does not work.
C) /usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig - works.
Solution: add .pc files location always as a Cygwin path into PKG_CONFIG_PATH.
3) CMake converts forward slashes to backslashes in PKG_CONFIG_PATH on Cygwin.
It happens due to the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21629. It prevents using the workaround described in [2].
Solution: manually update the function _pkg_set_path_internal() in the file C:/Program Files/CMake/share/cmake-3.x/Modules/FindPkgConfig.cmake. Comment/remove the line:
file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
4) CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH have no effect on pkg-config in Cygwin.
Reason: the bug https://gitlab.kitware.com/cmake/cmake/-/issues/21775.
Solution: Use only PKG_CONFIG_PATH as an environment variable if you run CMake builds on Cygwin. Forget about CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH.
Install mingw64 from https://sourceforge.net/projects/mingw-w64/. Avoid program files/(x86) folder for installation. Ex. c:/mingw-w64
Download pkg-config__win64.zip from here
Extract above zip file and copy paste all the files from pkg-config/bin folder to mingw-w64. In my case its 'C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin'
Now set path = C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin
taddaaa you are done.
If you find any security issue then follow steps as well
Search for windows defender security center in system
Navigate to apps & browser control> Exploit protection settings> Program setting> Click on '+add program customize'
Select add program by name
Enter program name: pkgconf.exe
OK
Now check all the settings and set it all the settings to off and apply.
Thats DONE!
Another place where you can get more updated binaries can be found at Fedora Build System site. Direct link to mingw-pkg-config package is: http://koji.fedoraproject.org/koji/buildinfo?buildID=354619
for w64-based computers you have to install mingw64. If pkg-config.exe is missing then, you can refer to http://ftp.acc.umu.se/pub/gnome/binaries/win64/dependencies/
Unzip and copy/merge pkg-config.exe into your C:\mingw-w64 installation, eg. into on my pc into C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin
In 2022 VS Code works with CMake & pkgconfig out of the box (add pkgconf && vcpkg-pkgconfig-get-modules to your vcpkg.json)
From: https://github.com/JoinMarket-Org/joinmarket/wiki/Installing-JoinMarket-on-Windows
This guide describes how to install JoinMarket and its dependencies (python, libsodium, secp256k1) on Windows.
Some or all of this may or may not work for all versions of Windows. Reports appreciated. It is not claimed to be in any way comprehensive. Verification of downloads are your own responsibility.
Install JoinMarket - go to https://github.com/JoinMarket-Org/joinmarket/releases and download the most recent release. Unzip it into any location you choose.
You will need to install MinGW from here or go to their website. After a few introductory screens, you will be shown a windows with some optional components that you have to choose; this basic setup is sufficient:
From "Basic Setup" in the left menu:
mingw-developer-toolkit
mingw32-base
mingw32-gcc-g++
msys-base
Once you have chosen these, choose "Update" from the main menu first item. These components will be installed into C:\MinGW\bin. Once that is complete, you should have this dll: libgcc_s_dw2-1.dll in that folder C:\MinGW\bin, along with a lot of other files; I'm mentioning this file explicitly, since it's needed specifically for libsecp256k1 to operate in this setup.
Next, you must make sure C:\MinGW\bin is added to your PATH variable. Here's one guide to how to do that; you must append ;C:\MinGW\bin to the end of the path before continuing.
Install Python from https://www.python.org/ftp/python/2.7.11/python-2.7.11.msi. Run the executable. Choose to install the feature Add python.exe to Path (it's the last option in the installer, off by default - switch it on) on local hard drive during installation; Python should then be installed in C:\Python27 (EXTRA NOTE: the most recent 2.7 installation linked here seems to install pip automatically, which is very useful for step 4)
Check that Python runs. Open a new command prompt as administrator by typing cmd.exe into the Start menu and pressing Ctrl+Shift+Enter. Type python and you should see something like:
Python 2.7.11 (default....
....
>>>
Exit the Python console with exit() or by pressing Ctrl+C. Now, make sure your version of pip is up to date: run the command: python -m pip install --upgrade pip.
Go to the directory C:\Python27\Lib\distutils and add a new file, called distutils.cfg. Inside it, put:
[build]
compiler=mingw32
Close and save the file.
Next, you need to install the dll for libnacl. First go to https://download.libsodium.org/libsodium/releases/ and choose the file libsodium-1.0.4-msvc.zip to download. Unzip anywhere, and then copy the file libsodium.dll from the directory \Win32\Release\v120\dynamic (do not use v140), and paste it into root joinmarket directory (the same directory where README.md lives). Then you need to address the Visual C++ 2013 runtime dependency. Do so by going to www.microsoft.com/en-us/download/details.aspx?id=40784 and clicking Download. Choose x86 even on a 64-bit system, and run the executable.
Note that after doing this, you must run pip install -r requirements-windows.txt from the Joinmarket root directory (where the README.md file is) and should not get an error message (this will install/check the python packages libnacl and secp256k1(-transient)).

Resources