11
votes

I know this is maybe a silly question but I am trying to export my terraform path into my linux path.

My terraform executable sits in a terraform folder under /usr/local/terraform.

I therefore did export PATH=$PATH:/usr/local/terraform/terraform

However, When i try and do terraform (going straight into terminal and type in terraform)it doesnt run. Only when I cd to usr/local/terraform and do a ./terraform then the executable runs.

What am i doing wrong?

4

4 Answers

40
votes

Just copy your terraform binary and place it in /usr/local/bin/

sudo mv terraform /usr/local/bin

You can now access terraform from your terminal from anywhere.

3
votes

Your PATH should list the directory the executable is in, not the executable itself:

export PATH=$PATH:/usr/local/terraform/
1
votes

You can try this:

cd /usr/bin
sudo ln -s /usr/local/terraform terraform

And then:

source ~/.profile
-3
votes

Quick Installation using Homebrew

check this video

or

steps below

Step 1:

Open https://brew.sh/

enter image description here

Copy the URL that showed in the above screenshot

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Paste copied URL in the terminal and hit return/enter key

Once you have done with Homebrew installation follow Step 2:

Step 2: Download terraform from https://www.terraform.io/downloads.html

extract downloaded zip terraform file

Now you will have one filename terraform on downloaded folder

For instance

/Users/username/downloads/terraform

Step 3:

Open a terminal

cd: change directory to /Users/username/downloads/terraform

Step 4:

run brew install terraform in the terminal