89luca89 / distrobox

Use any linux distribution inside your terminal. Enable both backward and forward compatibility with software and freedom to use whatever distribution you’re more comfortable with. Mirror available at: https://gitlab.com/89luca89/distrobox
https://distrobox.it/
GNU General Public License v3.0
9.87k stars 406 forks source link

/home/USER/.local/bin/distrobox-create: 1: eval: tmpdir: parameter not set #1370

Closed redbeardymcgee closed 5 months ago

redbeardymcgee commented 5 months ago

Describe the bug Uhm...

To Reproduce test.ini

[test]
init_hooks='sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin"'

distrobox assemble create --replace --file ./test.ini

Expected behavior Build the container, with chezmoi bootstrapped into $HOME/.local/bin

Host system podman 3.4.4 distrobox 1.7.2 Pop!OS 22.04

curl -s https://raw.githubusercontent.com/89luca89/distrobox/main/install | sh -s -- --next --prefix ~/.local

Additional context test.log

redbeardymcgee commented 5 months ago

If I'm reading this line correctly from the log, it looks like you dropped the surrounding single quotes ' somewhere while trying to sanitize the input.

128 │ + eval /home/josh/.local/bin/distrobox-create --yes -v --name test --init-hooks ": │ ; sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin""

Here I see that perhaps the culprit is somewhere here, as the outer quotes are lost now.

  58   │ + echo init_hooks='sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin"'
  59   │ + run_distrobox test
  60   │ + name=test
  61   │ + [  !=  ]
  62   │ + [ -e /tmp/tmp.Enf9OKt7OV ]
  63   │ + . /tmp/tmp.Enf9OKt7OV
  64   │ + init_hooks=sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "$HOME/.local/bin"

Here is the result of trying to embed and escape more quotes, like so:

init_hooks='"sh -c \"$(curl -fsLS get.chezmoi.io)\" -- -b \"$HOME/.local/bin\""'

Error: error inspecting object: no such container "#!/bin/sh

# chezmoi install script

... it's the whole install script
89luca89 commented 5 months ago

You need to also escape the dollarsign, as it will be evaluated by your current shell, not inside the container

so:

init_hooks='sh -c \"\$(curl -fsLS get.chezmoi.io)\"'

If you don't escape the $( this will be evaluated by your current shell BEFORE going to distrobox this is valid for every script and shell command, not a distrobox exclusive

This works indeed

image