-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
Python error when executing :shell or :term #1033
Comments
I've noticed the encoding is stripped when in the MacVim terminal: From a Mac terminal: From within MacVim via the :term command: |
This is related to starting MacVim directly (as an App). If I start MacVim via:
In a Mac terminal it works fine - so it has to the encoding being stripped when running directly. Any idea how to correct this? |
@ir0nh34d Thank you for an issue I confirm it, but I don't know where it goes from yet. |
Simply checking: |
I'll check why this is happens in the first place. It's easy to make a fix when you know where things come from |
Fair enough - I think it's due to the fact that macOS sets the language at a system level, but there doesn't seem to be a system setting for encoding, so the $LANG variable passed to applications lacks the encoding value. That said, this is pure guessing on my part. |
I figured out a temporary fix - in my .gvimrc (so as to not affect terminal vim) I set: |
Thanks for pointing this out. I need to think about how to solve this but I suspect we need to make the GUI version just inject the |
Actually looking through the code, I think we just need to call |
How iTerm re-computes locale: |
@ychin , I'm assuming python is used as an interpreter of some sort in :terminal mode (I don't specifically invoke python)? As per the python error, it's expecting the encoding to be specified as part of the locale. |
It turns out one of the commands I have in my .zshrc invokes python (https://github.com/nvbn/thefuck) so that's what is calling python when a shell starts. |
When launching MacVim not from terminal, macOS doesn't set the $LANG environment variable, and the locale API doesn't have a way to return the encoding (probably because everything is UTF-8). As such Vim would set the locale to something like "en_US", which breaks certain tools that expects an encoding part set. Fix this by simply appending ".UTF-8" to the constructed locale (e.g. "en_US.UTF-8") if $LANG doesn't exist. This makes sense as we default to UTF-8 in MacVim and macOS is basically UTF-8 native anyway. Fix macvim-dev#1033
When launching MacVim not from terminal, macOS doesn't set the $LANG environment variable, and the locale API doesn't have a way to return the encoding (probably because everything is UTF-8). As such Vim would set the locale to something like "en_US", which breaks certain tools that expects an encoding part set. Fix this by simply appending ".UTF-8" to the constructed locale (e.g. "en_US.UTF-8") if $LANG doesn't exist. This makes sense as we default to UTF-8 in MacVim and macOS is basically UTF-8 native anyway. Also, add a test that will make sure this is the case. Fix macvim-dev#1033
When launching MacVim not from terminal, macOS doesn't set the $LANG environment variable, and the locale API doesn't have a way to return the encoding (probably because everything is UTF-8). As such Vim would set the locale to something like "en_US", which breaks certain tools that expects an encoding part set. Fix this by simply appending ".UTF-8" to the constructed locale (e.g. "en_US.UTF-8") if $LANG doesn't exist. This makes sense as we default to UTF-8 in MacVim and macOS is basically UTF-8 native anyway. Also, add a test that will make sure this is the case. Fix macvim-dev#1033
This should be fixed and will be released soon. |
I've built from source and can confirm the issue has been addressed - thanks for the fix! |
I want to remind, that iTerm has resigned from this method |
What do you mean @eirnym? Care to elaborate? |
Yes, I've posted few comments above the link to a commit how currently iTerm computes LANG variable. I searched there for the term I don't know exact reasons why they resign from just appending a My guess, that they tried to run iTerm2 under Also they commented out setting of other |
They are just slapping "UTF-8" in the end of the |
Vim patch 8.2.539 General: - MacVim now reports its app category to be "Productivity" for Screen Time. macvim-dev#1032 Fixes: - Fix MacVim not reporting its version number correctly. macvim-dev#1011 - Fix mvim:// protocol handler not handling line number. macvim-dev#1020 - Fix opening MacVim from the Dock not setting UTF.8 in locale. macvim-dev#1033 - Buffer menu now doesn't show stale menu items from command-line windows or terminal windows. macvim-dev#1025 Targets macOS 10.9+ Script interfaces have compatibility with these versions: TODO - Lua 5.3 - Perl 5.18 - Python2 2.7 - Python3 3.7 - Ruby 2.7
Thank you, I see now. I'm fine with it, as I never met any other encodings in macOS (I'm a user since 10.6) |
Vim patch 8.2.539 General: - MacVim now reports its app category to be "Productivity" for Screen Time. #1032 Fixes: - Fix MacVim not reporting its version number correctly. #1011 - Fix mvim:// protocol handler not handling line number. #1020 - Fix opening MacVim from the Dock not setting UTF-8 in locale. #1033 - Buffer menu now doesn't show stale menu items from command-line windows or terminal windows. #1025 Targets macOS 10.9+ Script interfaces have compatibility with these versions: - Lua 5.3 - Perl 5.18 - Python2 2.7 - Python3 3.7 - Ruby 2.7
When I execute :shell or :term I get the following error:
Fatal Python error: config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed
Python runtime state: preinitialized
How do I correct this?
The text was updated successfully, but these errors were encountered: