-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homebrew error when running the post-generation scripts in Ubuntu 20.04 #3478
Comments
Hey, @olandese ! |
Hello @olandese, |
Hi @Darleev ,Yes, I am using all the scripts of the packer template in the git repo, homebrew.sh is there, did you applied the steps as I described after the VM creation? |
@olandese Could you please provide us PATH variable from the machine where the problem appears? I tried to build machines on my own, and execute post-generation scripts, but everything works fine. |
@Darleev I recreate the VM, this is the output of running $PATH for the admin (olandese) user configured for this VM when created: olandese@vmssaab00000000:~$ echo $PATH But if I run the script with this admin user like:
I get this: olandese@vmssaab00000000:~$ find /opt/post-generation -mindepth 1 -maxdepth 1 -type f -name '*.sh' -exec bash {} ; If I then run sudo -i and then echo $PATH: root@vmssaab00000000:~# echo $PATH Then running again: I get: root@vmssaab00000000:~# find /opt/post-generation -mindepth 1 -maxdepth 1 -type f -name '*.sh' -exec bash {} ; My FIXI fixed running the command:
But I really would like to know how is possible you are not getting the same issues as me |
@olandese yes, finally, I was able to reproduce the issue on our side, and it is required to adjust the documentation according to the fix provided by you. I think also need to mention that users should have sudo privileges to perform post-generation scripts. |
Thank you very much @Darleev ! |
@olandese we've merged the PR and now the information is available in our documentation. |
@olandese I'm going to close the issue. |
Hi,
I created my own Ubuntu 20.04 image using the original Packer file and scripts from this repo and it work great!
But running the post-generation script as documented in the create-image-and-azure-resources.md is giving an error:
/opt/post-generation/homebrew-permissions.sh: line 7: brew: command not found
/opt/post-generation/homebrew-permissions.sh: line 7: cd: HOME not set
fatal: not a git repository (or any of the parent directories): .git
Step to reproduce:
Option 1 - Manually execute the command:
Create a VM with the ubuntu image, login:
and then execute:
Option 2 with custom script extension:
{ "commandToExecute": "find /opt/post-generation -mindepth 1 -maxdepth 1 -type f -name '*.sh' -exec bash {} \\;" }
az vm extension set --vm-name <<your-vm-name>> --name customScript --resource-group <<your-resource-group>> --version 2.0 --publisher Microsoft.Azure.Extensions --settings ./config.json
Solution (maybe?)
it seems the brew command should first be loaded in the homebrew-permissions.sh file like:
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
The text was updated successfully, but these errors were encountered: