I am running into an error when executing ansible-lint
in a nix-shell when the ansible
package is also present in the environment. I just started looking into nix so I have a really hard time telling if i am causing this error or if its another problem. Could someone tell me if this is my fault?
pkgs="nixpkgs=https://github.com/NixOS/nixpkgs/archive/c5203abb1329f7ea084c04acda330ca75d5b9fb5.tar.gz"
# this executes successfully
nix-shell --pure --packages ansible-lint git -I ${pkgs} --run "ansible-lint playbook.yaml"
echo "$?"
# this crashes
nix-shell --pure --packages ansible ansible-lint git -I ${pkgs} --run "ansible-lint playbook.yaml"
echo "$?"
On crash, a python stacktrace is printed:
WARNING: PATH altered to include /nix/store/x9na3pxf7134pq7dkn1kgy9df6lf1z4v-python3-3.9.13/bin
Traceback (most recent call last):
File "/nix/store/385zg6szjfql36smhm1wladzjbl0jg8w-python3.9-ansible-core-2.13.0/bin/.ansible-config-wrapped", line 6, in <module>
from ansible.cli.config import main
ImportError: cannot import name 'main' from 'ansible.cli.config' (/nix/store/ga7vgfjikdk55mg3xqg68qn6ps4538nj-python3.9-ansible-core-2.12.5/lib/python3.9/site-packages/ansible/cli/config.py)
Traceback (most recent call last):
File "/nix/store/2qzmxfsn2g174lisjzf6ql50gbfwbms5-python3.9-ansible-lint-6.0.2/bin/.ansible-lint-wrapped", line 9, in <module>
sys.exit(_run_cli_entrypoint())
File "/nix/store/2qzmxfsn2g174lisjzf6ql50gbfwbms5-python3.9-ansible-lint-6.0.2/lib/python3.9/site-packages/ansiblelint/__main__.py", line 253, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/nix/store/2qzmxfsn2g174lisjzf6ql50gbfwbms5-python3.9-ansible-lint-6.0.2/lib/python3.9/site-packages/ansiblelint/__main__.py", line 166, in main
app = get_app()
File "/nix/store/2qzmxfsn2g174lisjzf6ql50gbfwbms5-python3.9-ansible-lint-6.0.2/lib/python3.9/site-packages/ansiblelint/app.py", line 205, in get_app
app = App(options=default_options)
File "/nix/store/2qzmxfsn2g174lisjzf6ql50gbfwbms5-python3.9-ansible-lint-6.0.2/lib/python3.9/site-packages/ansiblelint/app.py", line 41, in __init__
self.runtime = Runtime(isolated=True)
File "/nix/store/7p7nkm1f8hp64381vhrghk0agqbw20r7-python3.9-ansible-compat-2.0.4/lib/python3.9/site-packages/ansible_compat/runtime.py", line 84, in __init__
self.config = AnsibleConfig()
File "/nix/store/7p7nkm1f8hp64381vhrghk0agqbw20r7-python3.9-ansible-compat-2.0.4/lib/python3.9/site-packages/ansible_compat/config.py", line 422, in __init__
config_dump = subprocess.check_output(
File "/nix/store/x9na3pxf7134pq7dkn1kgy9df6lf1z4v-python3-3.9.13/lib/python3.9/subprocess.py", line 424, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/nix/store/x9na3pxf7134pq7dkn1kgy9df6lf1z4v-python3-3.9.13/lib/python3.9/subprocess.py", line 528, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ansible-config', 'dump']' returned non-zero exit status 1.