'asdf plugin add giving "curl: (3) Illegal characters found in URL" with packer build

Packer version 1.8.0 https://releases.hashicorp.com/packer/1.8.0/packer_1.8.0_windows_amd64.zip

I am using packer vagrant builder to generate a vagrant-box for Ubuntu.18.04.

The hcl file which I am using to build a vagrant box using packer is as follows:-

packer{
  required_plugins {
    vagrant = {
      version = ">= v1.0.1"
      source = "github.com/hashicorp/vagrant"
    }

  }
}

source "vagrant" "example" {
  communicator    = "ssh"
  output_dir      = "newoutput"
  provider        = "virtualbox"
  skip_add        = true
  source_path     = "bento/ubuntu-18.04"
}


build {
  sources = ["source.vagrant.example"]

  provisioner "file" {
    destination = "/tmp/.tool-versions"
    source      = "assets/.tool-versions"
  }


  provisioner "shell" {
    environment_vars  = ["HOME_DIR=/home/vagrant", "DEBIAN_FRONTEND=noninteractive", "SSO_USERNAME=$sso_username"]
    execute_command   = "echo 'vagrant' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
    expect_disconnect = true
    scripts           = ["${path.root}/scripts/init.sh", "${path.root}/scripts/dev_tools.sh", "${path.root}/scripts/asdf.sh", "${path.root}/scripts/cleanup.sh"]
  }

}

I am getting following log trace when the asdf.sh:-

==> vagrant.example: Cloning into '/home/vagrant/.asdf'...
==> vagrant.example: Note: checking out '77fd510bdc56be317b31fff27b8a3b948e1d65f9'.
==> vagrant.example:
==> vagrant.example: You are in 'detached HEAD' state. You can look around, make
experimental
==> vagrant.example: changes and commit them, and you can discard any commits you make in this
==> vagrant.example: state without impacting any branches by performing another checkout.
==> vagrant.example:
==> vagrant.example: If you want to create a new branch to retain commits you create, you may
==> vagrant.example: do so (now or later) by using -b with the checkout command again. Example:
==> vagrant.example:
==> vagrant.example: git checkout -b
==> vagrant.example:
vagrant.example: -linux-amd64.tar.gz
==> vagrant.example: curl: (3) Illegal characters found in URL
==> vagrant.example: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vagrant.example: destroying Vagrant box...
==> vagrant.example: Deleting output directory...
Build 'vagrant.example' errored after 30 minutes 23 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> Wait completed after 21 minutes 25 seconds

==> Some builds didn't complete successfully and had errors:
--> vagrant.example: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.

The content of asdf.sh is :-


#!/bin/bash -i

sudo apt install libffi-dev libncurses5-dev zlib1g zlib1g-dev
sudo apt install libssl-dev
sudo apt install libreadline-dev libbz2-dev libsqlite3-dev

git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.10.0
echo ". $HOME/.asdf/asdf.sh" >> $HOME/.bashrc
. $HOME/.asdf/asdf.sh

asdf plugin-add python https://github.com/danhper/asdf-python.git
asdf plugin add awscli
asdf plugin-add jq https://github.com/AZMCode/asdf-jq.git
asdf plugin-add yq https://github.com/sudermanjr/asdf-yq.git
asdf plugin-add helm https://github.com/Antiarchitect/asdf-helm.git
asdf plugin-add kubectl https://github.com/asdf-community/asdf-kubectl.git
asdf plugin-add kubectx https://github.com/virtualstaticvoid/asdf-kubectx.git
asdf plugin-add kubetail https://github.com/janpieper/asdf-kubetail.git
asdf plugin-add sops https://github.com/feniix/asdf-sops.git
cp /tmp/.tool-versions .tool-versions
[ -f .tool-versions ] && asdf install


I have also tried running it by adding $'\r' at the end of the urls but still got the same error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source