Skip to content

Failed to start VM when I want to modify PATH env var from env section in yaml template #2470

@szombi

Description

@szombi

Description

Hello!

I try to use this in my yaml template:

env:
  PATH: /custom/bin:"${PATH}"

But it is not working and the limactl start fails with this error:

INFO[0552] [hostagent] Waiting for the essential requirement 2 of 2: "user session is ready for ssh" 
INFO[0592] [hostagent] Waiting for the essential requirement 2 of 2: "user session is ready for ssh" 
FATA[0620] did not receive an event with the "running" status

After a little investigation I found this entry in /var/log/cloud-init-output.log:

+ exec /mnt/lima-cidata/boot.sh
/mnt/lima-cidata/boot.sh: 24: sed: not found
2024-07-05 18:45:11,410 - cc_scripts_per_boot.py[WARNING]: Failed to run module scripts_per_boot (per-boot in /var/lib/cloud/scripts/per-boot)
2024-07-05 18:45:11,410 - util.py[WARNING]: Running module scripts_per_boot (<module 'cloudinit.config.cc_scripts_per_boot' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_per_boot.py'>) failed
Cloud-init v. 24.1.3-0ubuntu3.3 finished at Fri, 05 Jul 2024 18:45:11 +0000. Datasource DataSourceNoCloud [seed=/dev/vdb][dsmode=net].  Up 7.02 seconds

I checked a little the boot.sh probably this part can fail I think:

while read -r line; do
# pam_env implementation:
# - '#' is treated the same as newline; terminates value
# - skip leading tabs and spaces
# - skip leading "export " prefix (only single space)
# - skip leading quote ('\'' or '"') on the value side
# - skip trailing quote only if leading quote has been skipped;
# quotes don't need to match; trailing quote may be omitted
line="$(echo "$line" | sed -E "s/^[ \\t]*(export )?//; s/#.*//; s/(^[^=]+=)[\"'](.*[^\"'])?[\"']?$/\1\2/")"
[ -n "$line" ] && export "$line"
done <"${LIMA_CIDATA_MNT}"/etc_environment

I'm new so I'm open for better solutions to modify the PATH var instead of using env section.
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions