hashicorp / hashicorp/packer

use_linux_pathing = true still expects a Windows Path

Open
#12,848 2 comments 0 reactions 0 assignees View on GitHub
bug stage/waiting-reply
Dominant language
Go
Stars
15.8k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

#### Overview of the Issue

I'm trying to leverage shell-local to do some preparation steps before a packer build in my builder, and I'm doing my testing from WSL. According to the [example in the docs](https://developer.hashicorp.com/packer/docs/provisioners/shell-local), I can run a bash script and seemingly use a Linux-style path. However, I receive the following error when I do so:

```
There was an error splitting your absolute path; expected to find a drive
following the format ':/' but did not: absolute path:
/home//test/scripts/test.sh
```

#### Reproduction Steps

Steps to reproduce this issue:

1. Create a simple packer file using the `null` source and builder
2. Use a small bash script that echoes a message.
3. Run `packer validate .` or `packer build .`

### Packer version

Packer v1.10.1

### Simplified Packer Template

```hcl
source "null" "test-shell-local" {
ssh_host = "127.0.0.1"
ssh_username = ""
ssh_password = ""
}

build {
sources = ["sources.null.test-shell-local"]

provisioner "shell-local" {
# Making WSL-friendly
environment_vars = ["SHELLLOCALTEST=ShellTest3"]
execute_command = ["bash", "-c", "{{.Vars}} {{.Script}}"]
use_linux_pathing = true
script = "./scripts/test.sh"
}

}
```

### Operating system and Environment details

OS: Windows 11 Pro
Windows Version: 23H2
Windows Build: 22631.3155
WSL2 version: 2.0.9.0
Ubuntu version: 22.04.04

### Log Fragments and crash.log files

```bash
Error: Failed preparing provisioner-block "shell-local" ""
on test.pkr.hcl line 10:

(source code not available)
on test.pkr.hcl line 10:

(source code not available)
There was an error splitting your absolute path; expected to find a drive

following the format ':/' but did not: absolute path:
/home//test/scripts/test.sh

There was an error splitting your absolute path; expected to find a drive
2024/02/17 10:11:54 [INFO] (telemetry) Finalizing.
following the format ':/' but did not: absolute path:
/home//test/scripts/test.sh
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.