coder / modules

A collection of Terraform Modules to work with Coder.
https://registry.coder.com
Apache License 2.0
23 stars 20 forks source link

Dotfiles fails: /bin/sh: 2: Bad substitution #214

Open jaulz opened 6 months ago

jaulz commented 6 months ago

The dotfiles modules fails on my side: image

I added the module like this:

module "dotfiles" {
  source = "https://registry.coder.com/modules/dotfiles"
  agent_id = coder_agent.workspace.id
}

and specified this repository. Is there anything else I need to set up?

matifali commented 6 months ago

Hi @jaulz, this module uses coder dotfiles to setup/install the dotfiles, which requires the presence of a script. It looks like there is no script in your dotfiles repo. Please see this for more details: https://coder.com/docs/v2/latest/dotfiles#setup-script-support

jaulz commented 6 months ago

@matifali thanks for the feedback! In fact, I checked the documentation but it sounded to me that the script is optional is and if it doesn't exist the configuration files are copied only.

matifali commented 6 months ago

@jaulz can you manually run coder dotfiles <your-dotfiles-repo> from within your workspace and see if it works? This will help us identify if the issue is with the module or the coder dotfiles command.

jaulz commented 6 months ago

@matifali it's also not really working: image

Maybe because there is already other stuff in the folder (e.g. code-server from other module)? image

matifali commented 6 months ago

The issue is with coder dotfiles and not the module, so I moved it here to this repo.

mafredri commented 6 months ago

@matifali to me this looks problematic: https://github.com/coder/modules/blob/f8faea1855fb5fbb4db99d34421b5d6999b17ca3/dotfiles/main.tf#L31

We should make sure this check is /bin/sh compatible, if we need it at all. That seems to be the source of the bad substitution error.

Perhaps that check is better done in terraform? Or perhaps the trim spaces and then just check for emptyness in the script. Or not create the script if empty.