Habitat: possible incompatibility between runtime environment variables and the `update_pkg_version` helper function

Created on 15 Dec 2017  路  14Comments  路  Source: habitat-sh/habitat

Attempting to set PYTHONPATH via push_runtime_env in a plan, where the same plan is using the update_pkg_version helper function, I see:

PYTHONPATH=/hab/pkgs/core/python/3.6.3/20171014214215/lib/python3.6/site-packages:/hab/pkgs/<origin>/<pip_module>/__pkg__version__unset__/20171215115627/lib/python3.6/site-packages

cc: @christophermaier

A-plan-build L-shell Bug

All 14 comments

This reminds me of https://github.com/habitat-sh/habitat/issues/3832

Might be the same reason?

@bixu Thanks for raising this. I have a good idea of what's happening, and will try to work out a fix soon.

@bixu I haven't been able to replicate this. Do you have a plan.sh that illustrates this?

Try pushing an env var using the core/aws-cli plan as a template

I suspect it is an issue with setting or pushing a value based on pkg_path during do_setup_environment. do_setup_environment_wrapper is called before do_before and do_before is the earliest documented opportunity to call update_pkg_version.

@bixu I still can't replicate it 鈽癸笍

I modified the core/aws-cli plan file by adding:

do_setup_environment() {
    push_runtime_env PYTHONPATH ${pkg_prefix}/lib
}

(not caring whether that's a real path or not)

After building, my RUNTIME_ENVIRONMENT file looks like this:

PATH=/hab/pkgs/core/aws-cli/1.14.11/20171216142222/bin:/hab/pkgs/core/python/3.6.3/20171014214215/bin:/hab/pkgs/core/groff/1.22.3/20170514000731/bin
PYTHONPATH=/hab/pkgs/core/aws-cli/1.14.11/20171216142222/lib

This is using core/hab-plan-build/0.50.3/20171202005315 (i.e., current stable).

What exactly are you setting your PYTHONPATH to in your plan?

@robbkidd That shouldn't be an issue here, because we explicitly account for the environment in update_pkg_version: https://github.com/habitat-sh/habitat/blob/84f0038f789cdd580ca16fb54e0e6cf549f7ffc0/components/plan-build/bin/public.sh#L580-L583

I鈥檒l try to recreate on Monday.

@christophermaier, I've not been able to reproduce this so I'm closing the issue.

I believe we need to reopen this.
Values get populated and fixed in update_pkg_version but are not re-exported to env.

I have something like this:

pkg_name=testplan
....
pkg_version() {
  echo 42
}
do_setup_environment() {
    set_runtime_env JBOSS_HOME "$pkg_prefix"
}

do_before() {
    do_default_before
    update_pkg_version
    attach
}

do_build() {
  java_opts="-Xmx4g -Djboss.home=$JBOSS_HOME"
  echo "$java_opts"  # ooops.
}
...

This results to:

[1] testplan(do_before)> env
...
JBOSS_HOME=/hab/pkgs/my/testplan/__pkg__version__unset__/20190409111449
[2] testplan(do_before)> echo "${__runtime_environment[@]}"
/hab/pkgs/my/testplan/1/20190409111449 /hab/pkgs/core/jre8/8.192.0/20190115162808

@jsirex I'm looking into this now.

@jsirex Ugh, yep, this needs to be reopened. The metadata files are being written out properly, but we're not adding the updated values back to the live environment in the studio after they've been updated.

I'll try and get to this in the next few days.

In the meantime, a workaround could be something like this:

do_build() {
    java_opts="-Xmx4g -Djboss.home=${__runtime_environment[JBOSS_HOME]}"
    ...
}

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We value your input and contribution. Please leave a comment if this issue still affects you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miketheman picture miketheman  路  4Comments

juliandunn picture juliandunn  路  3Comments

ShalokShalom picture ShalokShalom  路  3Comments

bodymindarts picture bodymindarts  路  4Comments

mgamini picture mgamini  路  4Comments