tgswitch icon indicating copy to clipboard operation
tgswitch copied to clipboard

Permissions issues on linux

Open primeroz opened this issue 5 years ago • 9 comments

Same issue as https://github.com/warrensbox/terraform-switcher/issues/33

$ tgswitch     
✔ 0.18.7
lstat /usr/local/bin/terragrunt: no such file or directory
symlink /home/user/.terragrunt.versions/terragrunt_0.18.7 /usr/local/bin/terragrunt: permission denied
2019/07/04 09:32:37 Unable to create symlink. You must have SUDO privileges symlink /home/user/.terragrunt.versions/terragrunt_0.18.7 /usr/local/bin/terragrunt: permission denied 

we need the same solution to use a configuration file to specify the destination bin link.

Thanks!

primeroz avatar Jul 04 '19 08:07 primeroz

I can confirm that behavior .

⇒  tgswitch                                                                                                                                                                  
✔ 0.19.21
symlink /home/xat/.terragrunt.versions/terragrunt_0.19.21 /usr/local/bin/terragrunt: file exists
2019/09/02 15:11:58 Unable to create symlink. You must have SUDO privileges symlink /home/xat/.terragrunt.versions/terragrunt_0.19.21 /usr/local/bin/terragrunt: file exists 

Xat59 avatar Sep 02 '19 13:09 Xat59

This feature was added with MR #65. Upgrade tgswitch to get the latest version.

brew upgrade warrensbox/tap/tgswitch

Please test the latest release and let me know if there are any bugs.

Use custom installation location (For non-admin - users with limited privilege on their computers)

You can specify a custom binary path for your terragrunt installation

  1. Create a custom binary path. Ex: mkdir /Users/username/bin (replace username with your username)
  2. Add the path to your PATH. Ex: export PATH=$PATH:/Users/username/bin (add this to your bash profile or zsh profile)
  3. Pass -b or --bin parameter with your custom path to install terragrunt. Ex: tgswitch -b /Users/username/bin/terragrunt 0.14.1

warrensbox avatar Oct 20 '19 01:10 warrensbox

It does work but to be honest it would have been great to use the same way that "tfswitch" uses with the .toml file ... it is very likely that whoever use one tool use the other as well.

In the case of tgswitch i will have to setup an alias to the -b option

primeroz avatar Oct 21 '19 07:10 primeroz

Ok so before we need to reinstall tgswitch with the -b option that defines the path directory of the tgswitch binary :

$ export PATH=$PATH:~/.local/bin
$ wget https://raw.githubusercontent.com/warrensbox/tgswitch/release/install.sh
$ bash install.sh -b ~/.local/bin

warrensbox/tgswitch info checking GitHub for latest tag
warrensbox/tgswitch info found version: 0.4.326 for 0.4.326/linux/amd64
warrensbox/tgswitch info installed /home/xat/.local/bin/tgswitch

Then, I am able to tgswitch, but there I need to use -b to define the complete location of the terragrunt binary :

$ tgswitch -b ~/.local/bin/terragrunt 
✔ 0.28.7
Downloading https://github.com/gruntwork-io/terragrunt/releases/download/v0.28.7/terragrunt_linux_amd64 to terragrunt_linux_amd64
Downloading ...
36705151 bytes downloaded.
Switched terragrunt to version "0.28.7" 

So, to resume :

  • use -b option when installing to define the directory path of the tgswitch binary
  • use -b option to specify the complete path of the terragrunt symlink

Xat59 avatar Mar 05 '21 09:03 Xat59

@Xat59 what works for me is to have an alias and expand the PATH

tgswitch='$HOME/bin/tgswitch -b $HOME/bin/terragrunt'

primeroz avatar Mar 05 '21 09:03 primeroz

@primeroz yeah it works after tgswitch reinstallation like I said here : https://github.com/warrensbox/tgswitch/issues/54#issuecomment-791280909

@warrensbox maybe the installation instructions must be reviewed for unprivileged users like I said before

Xat59 avatar Mar 05 '21 09:03 Xat59

I'll add the toml file option

warrensbox avatar Nov 15 '21 08:11 warrensbox

siempre que intento el ./install.sh el zsh me da permission denied que pueod hacer para arreglarlo chmod -x install.sh

┌──(kali㉿kali)-[~/Desktop/DARKARMY] └─$ ./install.sh zsh: permission denied: ./install.sh

Deltaxzdev avatar Jan 14 '22 22:01 Deltaxzdev

btw. you can also use tenv that support Terraform as well as OpenTofu (and Terragrunt :) ) in one tool. It allow you to simplify version management and can do much more, than tgswitch.

kvendingoldo avatar Apr 03 '24 14:04 kvendingoldo