0

I've been wondering if there is a way to set the PATH system variable using other system variables. For example my /etc/environment currently looks like

PATH="........other stuff........ :$SCALA_HOME/bin"
SCALA_HOME="/usr/lib/scala/scala-2.11.4"

But I can't get the path to actually use the SCALA_HOME variable I defined. When I type 'scala' into the terminal it isn't recognized as a command.

I know I could just add the actual value of SCALA_HOME to the path like this...

PATH="........other stuff........ :/usr/lib/scala/scala-2.11.4/bin"

But I feel like this is repetitive and there should be a way to do it the way I was trying.

Anyone know how to do this?

Ryan Stull
  • 417
  • 2
  • 7
  • 20

1 Answers1

1

As muru said, this is a duplicate question. You can't do it in /etc/environment, but you can create e.g. /etc/profile.d/mypath.sh and give it this contents:

export PATH="$PATH:$SCALA_HOME/bin"

Reference: EnvironmentVariables

Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94