modules icon indicating copy to clipboard operation
modules copied to clipboard

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

Open jaulz opened this issue 2 years ago • 6 comments

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?

jaulz avatar Dec 16 '23 18:12 jaulz

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

matifali avatar Dec 17 '23 13:12 matifali

@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.

jaulz avatar Dec 17 '23 13:12 jaulz

@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.

matifali avatar Dec 17 '23 13:12 matifali

@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

jaulz avatar Dec 17 '23 19:12 jaulz

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

matifali avatar Dec 18 '23 11:12 matifali

@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.

mafredri avatar Dec 19 '23 19:12 mafredri