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

Possible failure of locale env propagation to language server #22975

Open
1 task done
rosingrind opened this issue Jan 10, 2025 · 1 comment
Open
1 task done

Possible failure of locale env propagation to language server #22975

rosingrind opened this issue Jan 10, 2025 · 1 comment
Labels
admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue

Comments

@rosingrind
Copy link

Check for existing issues

  • Completed

Describe the bug / provide steps to reproduce it

Using ansible-language-server v0.1.0 in Zed 0.168.2 and getting this error:

Path for lint: /Users/beno/.pyenv/shims/ansible-lint
Validating using ansible-lint
[ansible-lint] ERROR: Ansible requires the locale encoding to be UTF-8; Detected None.
Traceback (most recent call last):
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansiblelint/__main__.py", line 400, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
             ^^^^^^^^^^^^^^
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansiblelint/__main__.py", line 336, in main
    app = get_app(
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansiblelint/app.py", line 405, in get_app
    app = App(options=options)
          ^^^^^^^^^^^^^^^^^^^^
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansiblelint/app.py", line 51, in __init__
    self.runtime = Runtime(
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansible_compat/runtime.py", line 213, in __init__
    self.config = AnsibleConfig(cache_dir=self.cache_dir)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansible_compat/config.py", line 416, in __init__
    config_dump = subprocess.check_output(  # noqa: S603
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/subprocess.py", line 421, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ansible-config', 'dump']' returned non-zero exit status 1.

I don't understand where the problem lays, because launching Zed via logged in terminal session (both zed and open /Applications/Zed.app commands) does not cause this issue. Launching Zed not from logged in zsh session does cause the problem.
In both cases (launch it from shell or not), I do get the same log in Zed about set environment variables from shell:/bin/zsh, path:... and using project environment variables shell launched in "...", and both logged envs are 1:1 same - I'm lost, because if captured env are identical, why ansible-language-server performs like they are not?

Steps to reproduce:

export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init - zsh)"
  • install pyenv install pypy3.10-7.3.17, perform pyenv global pypy3.10-7.3.17 and install pip3 install ansible ansible-lint jmespath
  • check python3 --version
Python 3.10.14 (39dc8d3c85a7, Aug 27 2024, 20:40:24)
[PyPy 7.3.17 with GCC Apple LLVM 15.0.0 (clang-1500.3.9.4)]
  • check ansible --version
ansible [core 2.17.7]
  config file = None
  configured module search path = ['/Users/beno/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/beno/.pyenv/versions/pypy3.10-7.3.17/lib/pypy3.10/site-packages/ansible
  ansible collection location = /Users/beno/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/beno/.pyenv/versions/pypy3.10-7.3.17/bin/ansible
  python version = 3.10.14 (39dc8d3c85a7, Aug 27 2024, 20:40:24)[PyPy 7.3.17 with GCC Apple LLVM 15.0.0 (clang-1500.3.9.4)] (/Users/beno/.pyenv/versions/pypy3.10-7.3.17/bin/python)
  jinja version = 3.1.5
  libyaml = False
  • add ansible-language-server extension to Zed
  • make or clone basic ansible templates: git clone https://github.com/ansible/ansible-examples.git
  • open any project from repo via zed ./ansible-examples - works as intended 👍
  • open Zed via app icon and proceed to the same project - fails with error 👎

Also, noticed that everything works fine with python 3.10.14:

  • install pyenv install 3.10.14, perform pyenv global 3.10.14 and install pip3 install ansible ansible-lint jmespath
  • check python3 --version
Python 3.10.14
  • check ansible --version
ansible [core 2.17.7]
  config file = None
  configured module search path = ['/Users/beno/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/beno/.pyenv/versions/3.10.14/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/beno/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/beno/.pyenv/versions/3.10.14/bin/ansible
  python version = 3.10.14 (main, Jan 10 2025, 16:58:29) [Clang 16.0.0 (clang-1600.0.26.6)] (/Users/beno/.pyenv/versions/3.10.14/bin/python3.10)
  jinja version = 3.1.5
  libyaml = True
  • open any project from repo via zed ./ansible-examples - works as intended 👍
  • open Zed via app icon and proceed to the same project - works as intended 👍

The part of ansible-compat==24.10.0 python code that triggers fail is https://github.com/ansible/ansible-compat/blob/ba624e9511a76f29fd12cff3e01feef1458d3acf/src/ansible_compat/config.py#L416, it doesn't look like there is any code that may fail like this.
Setting "lsp.ansible-language-server.settings.validation.lint.path": "LC_ALL=en_US.UTF-8 ansible-lint" in global Zed config fixes the issue for me; there appears to be another following env issue (actually of same kind) when hovering over any part of Ansible YAML code in the editor window, and it can't be fixed with plugin settings:

Command failed: ansible-config dump
ERROR: Ansible requires the locale encoding to be UTF-8; Detected None.

I don't know for sure if there's a problem with Zed specifically, or with pypy and it's env propagation, but they seem to work bad together. Is there anything I miss or doing incorrect?

My locale output:

LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

Zed Version and System Specs

Zed: v0.168.2 (Zed)
OS: macOS 15.2.0
Memory: 48 GiB
Architecture: aarch64

If applicable, add screenshots or screencasts of the incorrect state / behavior

No response

If applicable, attach your Zed.log file to this issue.

Zed.log

2025-01-10T19:50:03.131405+03:00 [ERROR] oneshot canceled
2025-01-10T19:50:03.131674+03:00 [ERROR] oneshot canceled
2025-01-10T19:50:03.13187+03:00 [ERROR] oneshot canceled
2025-01-10T19:50:03.132118+03:00 [ERROR] oneshot canceled
2025-01-10T19:50:06.704235+03:00 [INFO] ========== starting zed ==========
2025-01-10T19:50:06.766956+03:00 [INFO] Opening main db
2025-01-10T19:50:06.767646+03:00 [INFO] Opening main db
2025-01-10T19:50:06.789062+03:00 [INFO] Using git binary path: Some("/Applications/Zed.app/Contents/MacOS/git")
2025-01-10T19:50:06.872858+03:00 [INFO] set environment variables from shell:/bin/zsh, path:/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS
2025-01-10T19:50:06.91974+03:00 [INFO] No prompt template overrides directory found at /Users/beno/.config/zed/prompt_overrides. Using built-in prompts.
2025-01-10T19:50:06.920077+03:00 [INFO] No prompt template overrides directory found at /Users/beno/.config/zed/prompt_overrides. Using built-in prompts.
2025-01-10T19:50:06.920891+03:00 [INFO] extensions updated. loading 29, reloading 0, unloading 0
2025-01-10T19:50:06.953031+03:00 [INFO] Opening main db
2025-01-10T19:50:06.988604+03:00 [INFO] Opening main db
2025-01-10T19:50:06.990832+03:00 [INFO] open paths ["/Users/beno/.profile"]
2025-01-10T19:50:06.990946+03:00 [INFO] open paths ["/Users/beno/.zprofile"]
2025-01-10T19:50:06.991079+03:00 [INFO] open paths ["/Users/beno/.zshenv"]
2025-01-10T19:50:06.991211+03:00 [INFO] open paths ["/Users/beno/.zshrc"]
2025-01-10T19:50:06.991851+03:00 [INFO] Opening main db
2025-01-10T19:50:07.000357+03:00 [INFO] building git repository, `.git` path in the worktree: ".git"
2025-01-10T19:50:07.10643+03:00 [INFO] using project environment variables shell launched in "/Users/beno/.profile". PATH="/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/beno/.pyenv/bin"
2025-01-10T19:50:08.012768+03:00 [INFO] attempting to start language server "ansible", path: "/Users/beno/Documents/Fork/personal/ansible-examples", id: 1
2025-01-10T19:50:08.012861+03:00 [INFO] attempting to start language server "bash-language-server", path: "/Users/beno/.zshenv", id: 2
2025-01-10T19:50:08.012985+03:00 [INFO] attempting to start language server "bash-language-server", path: "/Users/beno/.zprofile", id: 3
2025-01-10T19:50:08.013146+03:00 [INFO] attempting to start language server "bash-language-server", path: "/Users/beno/.zshrc", id: 4
2025-01-10T19:50:08.01328+03:00 [INFO] attempting to start language server "bash-language-server", path: "/Users/beno/.profile", id: 5
2025-01-10T19:50:08.014894+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:08.090296+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:08.104793+03:00 [INFO] using project environment variables shell launched in "/Users/beno/.zprofile". PATH="/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/beno/.pyenv/bin"
2025-01-10T19:50:08.215756+03:00 [INFO] using project environment variables shell launched in "/Users/beno/.zshrc". PATH="/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/beno/.pyenv/bin"
2025-01-10T19:50:08.316754+03:00 [INFO] using project environment variables shell launched in "/Users/beno/Documents/Fork/personal/ansible-examples". PATH="/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/beno/.pyenv/bin"
2025-01-10T19:50:08.42777+03:00 [INFO] using project environment variables shell launched in "/Users/beno/.zshenv". PATH="/Users/beno/.pyenv/shims:/Users/beno/.pyenv/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/beno/.pyenv/bin"
2025-01-10T19:50:08.644995+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:08.720885+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:08.783865+03:00 [INFO] starting language server process. binary path: "/Users/beno/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/beno/Documents/Fork/personal/ansible-examples", args: ["/Users/beno/Library/Application Support/Zed/extensions/work/ansible/node_modules/@ansible/ansible-language-server/bin/ansible-language-server", "--stdio"]
2025-01-10T19:50:08.866382+03:00 [WARN] unhandled capability registration: Registration { id: "674709f2-022a-4956-aec1-5ee86a76ec77", method: "workspace/didChangeConfiguration", register_options: Some(Object {"section": String("ansible")}) }
2025-01-10T19:50:09.047457+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:09.114976+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:09.182046+03:00 [INFO] starting language server process. binary path: "/Users/beno/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/beno", args: ["/Users/beno/Library/Application Support/Zed/extensions/work/basher/node_modules/bash-language-server/out/cli.js", "start"]
2025-01-10T19:50:09.182195+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:09.254813+03:00 [INFO] starting language server process. binary path: "/Users/beno/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/beno", args: ["/Users/beno/Library/Application Support/Zed/extensions/work/basher/node_modules/bash-language-server/out/cli.js", "start"]
2025-01-10T19:50:09.255+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:09.323051+03:00 [INFO] starting language server process. binary path: "/Users/beno/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/beno", args: ["/Users/beno/Library/Application Support/Zed/extensions/work/basher/node_modules/bash-language-server/out/cli.js", "start"]
2025-01-10T19:50:09.323238+03:00 [INFO] Node runtime install_if_needed
2025-01-10T19:50:09.391028+03:00 [INFO] starting language server process. binary path: "/Users/beno/Library/Application Support/Zed/node/node-v22.5.1-darwin-arm64/bin/node", working directory: "/Users/beno", args: ["/Users/beno/Library/Application Support/Zed/extensions/work/basher/node_modules/bash-language-server/out/cli.js", "start"]
2025-01-10T19:50:09.431435+03:00 [WARN] unhandled capability registration: Registration { id: "54fa1fa2-79f0-4669-8c12-2c24b69f99b6", method: "workspace/didChangeConfiguration", register_options: Some(Object {"section": String("bashIde")}) }
2025-01-10T19:50:09.431701+03:00 [WARN] unhandled capability registration: Registration { id: "534deabd-ea18-447d-91fd-f352a8119506", method: "workspace/didChangeConfiguration", register_options: Some(Object {"section": String("bashIde")}) }
2025-01-10T19:50:09.443136+03:00 [WARN] unhandled capability registration: Registration { id: "a96a4a70-24b3-45c6-8ea8-197878263a49", method: "workspace/didChangeConfiguration", register_options: Some(Object {"section": String("bashIde")}) }
2025-01-10T19:50:09.518344+03:00 [WARN] unhandled capability registration: Registration { id: "34b7658d-1ecb-46d2-9577-23a51dd121c8", method: "workspace/didChangeConfiguration", register_options: Some(Object {"section": String("bashIde")}) }

@rosingrind rosingrind added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Jan 10, 2025
@rosingrind
Copy link
Author

I can't reproduce this on Debian 12, tested via VMware. Could this be a specific issue with macOS or zsh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue
Projects
None yet
Development

No branches or pull requests

1 participant