Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed: set global app version #24

Open
kmptkp opened this issue Dec 7, 2022 · 2 comments
Open

failed: set global app version #24

kmptkp opened this issue Dec 7, 2022 · 2 comments

Comments

@kmptkp
Copy link

kmptkp commented Dec 7, 2022

While installing erlang and elixir, the role never gets past the step TASK [asdf : set global app versions]

The error is:

failed: [lxd] (item={'name': 'erlang', 'versions': ['25.1']}) => {"ansible_loop_var": "item", "changed": true, "cmd": ["bash", "-lc", "source /etc/profile.d/asdf.sh && asdf global erlang 25.1"], "delta": "0:00:00.182398", "end": "2022-12-07 19:43:49.179097", "item": {"name": "erlang", "versions": ["25.1"]}, "msg": "non-zero return code", "rc": 1, "start": "2022-12-07 19:43:48.996699", "stderr": "/home/foo/.asdf/lib/functions/versions.bash: line 67: /home/foo//home/foo/.tool-versions: No such file or directory", "stderr_lines": ["/home/foo/.asdf/lib/functions/versions.bash: line 67: /home/foo//home/foo/.tool-versions: No such file or directory"], "stdout": "", "stdout_lines": []}

failed: [lxd] (item={'name': 'elixir', 'versions': ['1.14']}) => {"ansible_loop_var": "item", "changed": true, "cmd": ["bash", "-lc", "source /etc/profile.d/asdf.sh && asdf global elixir 1.14"], "delta": "0:00:00.151380", "end": "2022-12-07 19:43:49.384590", "item": {"name": "elixir", "versions": ["1.14"]}, "msg": "non-zero return code", "rc": 1, "start": "2022-12-07 19:43:49.233210", "stderr": "/home/foo/.asdf/lib/functions/versions.bash: line 67: /home/foo//home/foo/.tool-versions: No such file or directory", "stderr_lines": ["/home/foo/.asdf/lib/functions/versions.bash: line 67: /home/foo//home/foo/.tool-versions: No such file or directory"], "stdout": "", "stdout_lines": []}

Notice the doubling of the path in /home/foo//home/foo/.tool-versions. This may (or may not!) be related to the fact that export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="/home/foo/.tool-versions" gets written to /etc/profile.d/asdf.sh (whereas the var name suggests that it should be ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=".tool-versions", thereby triggering the path-doubling). Changing that manually doesn't help as it gets overwritten on every ansible run.

The relevant part of my vars section:

asdf_user: foo
asdf_group: foo
asdf_version: "v0.10.2"
asdf_plugins:
  - name: erlang
    versions: ["25.1"]
    global: "25.1"
  - name: elixir
    versions: ["1.14"]
    global: "1.14"

Note that it uses asdf v0.10.2 versus v0.8.1 in defaults/main.yml.

Finally the role is just called with the role name (and works fine until the task setting globals), nothing special to show.

@kmptkp
Copy link
Author

kmptkp commented Dec 7, 2022

Indeed this issue is fixed by changing the task from:

- name: "set asdf_default_tool_versions_file based on home directory"
  set_fact:
    asdf_default_tool_versions_file: "{{ getent_passwd[asdf_user][4] }}/.tool-versions"
  when: asdf_dir is undefined and asdf_default_tool_versions_file is undefined

to

- name: "set asdf_default_tool_versions_file based on home directory"
  set_fact:
    asdf_default_tool_versions_file: ".tool-versions"
  when: asdf_dir is undefined and asdf_default_tool_versions_file is undefined

I'm not sure sure how this changes affects the v0.8-based versions, and it is a trivial 1-line change, so I haven't made a PR for now.

stephanGarland added a commit to stephanGarland/ansible-role-asdf that referenced this issue Jan 7, 2023
@fapeliberty
Copy link

FYI, from asdf v0.10.2, this file was added :

https://github.com/asdf-vm/asdf/blob/v0.10.2/lib/functions/versions.bash

and line 23, for global command, they force the use of $HOME.

fapeliberty added a commit to eliberty/ansible-role-asdf that referenced this issue Feb 7, 2023
klaus993 added a commit to lambdaclass/ansible-role-asdf that referenced this issue Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants