If I install Terraform via brew install terraform#0.12 , it installed latest version 0.12.31.
And then to use it I run command alias terraform=$(brew config | awk '/HOMEBREW_PREFIX:/ { print $2 }')/opt/terraform#0.12/bin/terraform.
But I need to use not the latest version, I want to use 0.12.29.
And I can install it via
brew install tfenv
tfenv install 0.12.29
tfenv use 0.12.29
But I don't know how to specify this version ( 0.12.29 ) in alias terraform=.
Have you heard of this project? https://tfswitch.warrensbox.com/Quick-Start/
It makes adjusting the current version of terraform a lot easier.
Same for terragrunt https://warrensbox.github.io/tgswitch/additional.html
Related
I installed an older version of terraform and the binary is in my downloads, how do I move it to another location? have to /opt/homebrew/Cellar/tfenv/3.0.0/versions/1.0.0/terraform
I used the method here: https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli
but I get: terraform is not a directory
think about using tfenv if you want to maintain different terraform versions in same PC.
By your path, it seems that you are using homebrew as a package manager.
Use these steps to install any version of terraform.
Install tfenv
brew install tfenv
List the available versions of terraform via tfenv (optional)
## To view all the available versions via tfenv.
tfenv list-remote
## tfenv list-remote | head -n <number_of_last_terraform_versions_you_want_to_list>
tfenv list-remote | head -n 20 ## example
To Install the required terraform version via tfenv
## tfenv install <terraform_version_you_want>
tfenv install 1.3.7
Switch to the version you installed via tfenv in the past or the last step.
## tfenv use <terraform_version_you_want>
tfenv use 1.3.7
I'm start using Terraform and I'm following the project updates on his Github repository.
I see new releases are available on releases section:
https://github.com/hashicorp/terraform/releases
I installed Terraform tool following the steps:
https://www.terraform.io/intro/getting-started/install.html
The new releases are a zip file with base code but I want to know how I can install it on my computer (OSX). What I downloaded when I installed for the first time was a zip file with just a "terraform" file as unix executable.
How I can generate this Unix executable from the zip available on the github releases section?
Any idea?
Thank you!
If you use Homebrew on MacOS already, you can install Terraform simply by
$ brew install terraform
and upgrade by
$ brew upgrade terraform
In fact, you might be interested in letting Homebrew also control other tools:
$ brew install awscli
$ brew install packer
$ brew cask install docker
$ brew cask install virtualbox
$ brew cask install vagrant
There are packages for each OS available on the Downloads Page.
Pick the appropriate package for your OS and download the zip file.
Extract the contents of the zip file, which should be a single terraform binary, into some reasonable location that's in your PATH (e.g. /usr/local/bin).
Add execute permissions: e.g. chmod u+x /usr/local/bin/terraform.
Run terraform and make sure you see the help text.
You could download the binary :
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
then :
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip
then :
mv terraform /usr/local/bin/
make sure to change ${TERRAFORM_VERSION} by the version you want to install
exemple :
0.13.2
**TLDR:
for Installation - brew install terraform
for Upgrade - brew upgrade terraform
for Verification - terraform --version
i'm new to using terraform, but to use terraform with multiple versions i use tfenv as terraform version manager
tfenv command
$ tfenv
tfenv 2.2.3
Usage: tfenv <command> [<options>]
Commands:
install Install a specific version of Terraform
use Switch a version to use
uninstall Uninstall a specific version of Terraform
list List all installed versions
list-remote List all installable versions
version-name Print current version
init Update environment to use tfenv correctly.
pin Write the current active version to ./.terraform-version
terraform currently i use
$ terraform -version
Terraform v1.1.9
on linux_amd64
list of terraform i have
$ tfenv list
1.2.0-rc2
* 1.1.9 (set by /home/takimi/.tfenv/version)
change terraform version
$ tfenv use 1.2.0-rc2
and if you want to use another terraform version you just install it with command tfenv install <terraform version>
Adding this response for the sake of completeness.
Hashicorp came up with their own brew taps for all Hashicorp products for MacOS platforms.
to upgrade ...
brew upgrade hashicorp/tap/{vault|consul|nomad|terraform|packer}
to install ...
brew install hashicorp/tap/{vault|consul|nomad|terraform|packer}
Reference : https://www.hashicorp.com/blog/announcing-hashicorp-homebrew-tap
This is detailed in the repository README under 'Developing Terraform' HERE
Essentially...
Ensure you've installed the GO programming language (version 1.7+ at the time of writing).
Create a GO workspace directory.
Create the $GOPATH environment variable pointing to the GO workspace directory you just created.
Add $GOPATH/bin to your $PATH
Clone the Terraform repo (or extract zip) to $GOPATH/src/github.com/hashicorp/terraform
Run make dev within the Terraform repo.
The Terraform binary should be created in $GOPATH/bin
I would recommend you follow the steps in the README as opposed to what I've written above it's comprehensive and may change.
You shouldn't need to do any of this unless your actively developing Terraform, otherwise stick with the installation method in the getting started guide.
To work with multiple Terraform versions, I'm using tfswitch. This allows you to switch between the terraform versions which makes things much easier.
You can find the documentation here.
I was able to use this tool to manage terraform versions: https://github.com/Zordrak/tfenv. The first step was to remove the existing installation with: rm '/usr/local/bin/terraform'
You could use something like asdf or tfenv to manage the terraform binaries.
Gives you the advantage of having the option to use different version per project if required.
$sudo apt-get upgrade
it will work in linux if you have setup right path for terraform
Is it possible to upgrade node right in place, instead of manually installing the latest stable version?
I have installed node.js version 5.0 with nvm, but now I want to update it to 5.4. I'm trying to avoid having to manually reinstall all of my global packages (e.g. by running npm install -g grunt-cli bower yo yoman-angular-generator blabla blablablabla...).
This may work:
nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION
For example:
nvm install 6.7 --reinstall-packages-from=6.4
then, if you want, you can delete your previous version with:
nvm uninstall OLD_VERSION
Where, in your case,
NEW_VERSION = 5.4
OLD_VERSION = 5.0
Alternatively, try:
nvm install stable --reinstall-packages-from=current
You can more simply run one of the following commands:
Latest version:
nvm install node --reinstall-packages-from=node
Stable (LTS) version: (if currently in use)
nvm install "lts/*" --reinstall-packages-from="$(nvm current)"
This will install the appropriate version and reinstall all packages from the currently used node version.
This saves you from manually handling the specific versions.
Kudos to #m4js7er for commenting about the LTS version.
⚡ TWO Simple Solutions:
To install the latest version of node and reinstall the old version packages just run the following command.
nvm install node --reinstall-packages-from=node
To install the latest lts (long term support) version of node and reinstall the old version packages just run the following command.
nvm install --lts /* --reinstall-packages-from=node
Here's a GIF animation to support this answer:
if you have 4.2 and want to install 5.0.0 then
nvm install v5.0.0 --reinstall-packages-from=4.2
the answer of gabrielperales is right except that he missed the "=" sign at the end. if you don't put the "=" sign then new node version will be installed but the packages won't be installed.
source: sitepoint
Here are the steps that worked for me for Ubuntu OS and using nvm
Go to nodejs website and get the last LTS version (for example the version will be: x.y.z)
nvm install x.y.z
# In my case current version is: 14.15.4 (and had 14.15.3)
After that, execute nvm list and you will get list of node versions installed by nvm.
Now you need to switch to the default last installed one by executing:
nvm alias default x.y.z
List again or run nvm --version to check:
Update: sometimes even if i go over the steps above it doesn't work, so what i did was removing the symbolic links in /usr/local/bin
cd /usr/local/bin
sudo rm node npm npx
And relink:
sudo ln -s $(which node) /usr/local/bin/nodesudo && ln -s $(which npm) /usr/local/bin/npmsudo && ln -s $(which npx) /usr/local/bin/npx
Node.JS to install a new version.
Step 1 : NVM Install
npm i -g nvm
Step 2 : NODE Newest version install
nvm install *.*.*(NodeVersion)
Step 3 : Selected Node Version
nvm use *.*.*(NodeVersion)
Finish
Bash alias for updating current active version:
alias nodeupdate='nvm install $(nvm current | sed -rn "s/v([[:digit:]]+).*/\1/p") --reinstall-packages-from=$(nvm current)'
The part sed -rn "s/v([[:digit:]]+).*/\1/p" transforms output from nvm current so that only a major version of node is returned, i.e.: v13.5.0 -> 13.
For Windows 11 this worked for me on cmd, used with admin rights:
Prerequisite, in case you just installed NVM, is to open a new cmd window after nvm installation.
See installation instructions here: https://github.com/coreybutler/nvm-windows
Get installed versions, using
nvm list
Get current version
nvm current
Install latest version
nvm install latest
Check installed versions to see for newer version, again using
nvm list
Set current version to the latest (cmd with admin rights), you just installed in the previous step
nvm use PUT_VERSION_NUMBER_TO_BE_USED
You can check again if the change was successful using
nvm list
Remove old version, if no longer needed
nvm remove PUT_VERSION_NUMBER_TO_BE_REMOVED
If you want to use the LTS version, install using
nvm install lts
Here's the steps to upgrade NodeJs version:
Run nvm install node (will install latest version). Alternatively, you
can specify a specific version by running nvm install <node_version>.
Run nvm use <node_version> to use it.
If you want to make it the default version on your machine, run nvm alias default <node_version>.
Additional notes:
To find out what node versions you have on your machine and which one is set as your default one, use nvm list command.
I tried installing node ver 0.8 on my ubuntu 12.04.It already has a node ver 0.6.12.The installation went suceesfully but when i type in
node --version
it still shows previous version.
i tried to remove previous version using sudo apt-get remove node but it says package node is not installed.But on trying node --version it shows 0.6.12
Why is it so??
The problem is, you need to replace the new location for node with the old in your PATH variable. If you have an old manual install, find the old path to node by running echo $PATH. Then run this command:
export PATH=${PATH%$OLD_NODE_PATH/bin*}$NEW_NODE_PATH/bin${PATH#$*OLD_NODE_PATH/bin}
Or if you are using an install from the apt-get repository, just run:
export PATH=$NEW_NODE_PATH/bin
And that should fix your problem. But there is a better way! The best tool to manage your node.js environment is NVM. It exactly like RVM for ruby and similar to virtualenv for python, if you are familiar with those tools. It allows you to switch versions of node and download new ones extremely efficiently, and is easy to use. Download and install with:
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
Then add this line to your bash (assuming you are running a bash shell) where it will be loaded (I prefer .bash_login for the personal stuff although it is not loaded by default):
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh
Source your bash script or restart the terminal then enter this command:
nvm install 0.8.0 && nvm use 0.8.0
This should set you up just fine. Although not necessary, you should probably get rid of all the other node installs, for the sake of tidiness. Check out their github page but to get you started here is a quick overview:
nvm ls # list all installed versions of node
nvm ls-remote # list all available versions of node
nvm install 0.9.8 # download and install node v0.9.8
nvm use 0.8.0 # switch current environment to use node v0.8.0
nvm alias default 0.8.0 # set 0.8.0 as default, you can use 'nvm use default'
nvm deactivate # use system install of node
nvm run default app.js # run app.js with default node version
I had this issue until I followd the directions on
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
which included running:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
first. Then running sudo apt-get install nodejs npm got me to 0.8.x
Also see: http://apptob.org/
Seem like you install nodejs package from Ubuntu repo and manually install node 0.8 after?
Try remove nodejs package.
The way to get a more recent version of Node.js is to add a PPA (personal package archive) maintained by NodeSource. This will probably have more up-to-date versions of Node.js than the official Ubuntu repositories.
First, you need to install the PPA in order to get access to its contents:
curl -sL https://deb.nodesource.com/setup | sudo bash -
The PPA will be added to your configuration and your local package cache will be updated automatically. After running the setup script from nodesource, you can install the Node.js package using the below command.
sudo apt-get install nodejs
You can check the node by using this command
node -v
I'm trying to get node.js and npm installed on my Ubuntu 11.10 installation, and I'm having a tricky time. I decided to go the route of downloading and compiling from the latest source because I want to use the new version of node.js - v0.6.0 instead of the older version that the synaptic package manager will install. However, I could not get npm set up correctly with it due to a "module not found" error. I was completely surprised at how little information I was able to find on the error.
Anyways, my goal here is to learn node.js, not to run a production environment. Should I give in and use v4.9 or is it really worth getting the newest version for the sake of learning, even if I have to go through the pain of keeping it updated and configuring it myself?
If you have Ubuntu, install it from Chris Lea's repo, it's always up to date with the last stable version (for ex now the version is 0.6.0 - as of today):
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Generally, you want to install node from source since the packages you find in package managers are usually out of date. 0.4.12 was the last stable before 0.6.0 that was released a few days ago. 0.4.9 is pretty out of date.
This is a old question, nowadays my preferred way to install node is by using nvm (Node Version Manager). This will allow you to have multiple versions of node installed and quickly switch version.
Installation:
Install C++ compiler
apt-get update
apt-get install build-essential libssl-dev
Install NVM
curl https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
source ~/.profile
Install node (select which version you want to install)
nvm install 6
Usage:
To set a default node version:
nvm alias default 0.12.7
To select a different installed version:
nvm use 4