Search code examples
macosshellenvironment-variablesfish

Add a relative path to $PATH on fish startup


I want to add ./bin directory (which is relative to current shell directory) to $PATH on fish startup. Note that fish is a shell.

echo $PATH
set PATH ./bin $PATH
echo $PATH

If I place these lines inside ~/.config/fish/config.fish the shell will echo the same collection of paths. Absolute paths are added properly.

If I open the shell and type the same set PATH ./bin $PATH inside some directory containing bin it is added successfully. However when there is no bin inside current directory it shows me an error.

set: Could not add component ./bin to PATH.
set: Value too large to be stored in data type

I'm running fish 1.23.1 on OS X Lion.


Solution

  • It seems like fish won't add a non-existing directory path to PATH. That applies to relative paths too. But if you create bin directory in your home directory set PATH ./bin $PATH will work properly on each startup since it is executed from home. This is kind of a hack though.