Skip to content

Commit

Permalink
win/os_env_exists(): workaround libuv bug neovim#10734
Browse files Browse the repository at this point in the history
os_env_exists() fails on MSVC build:
    os_env_exists:104: uv_os_getenv(EMPTY_VAR) failed: -4094 UNKNOWN

- Revert 396a394
- HACK: Windows: return TRUE if uv_os_getenv() returns UV_UNKNOWN, until
  libuv bug is fixed: libuv/libuv#2413

ref neovim@396a394#r34642361
  • Loading branch information
justinmk committed Aug 10, 2019
1 parent 0062c65 commit 278c5d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/nvim/os/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ bool os_env_exists(const char *name)
assert(r != UV_EINVAL);
if (r != 0 && r != UV_ENOENT && r != UV_ENOBUFS) {
ELOG("uv_os_getenv(%s) failed: %d %s", name, r, uv_err_name(r));
#ifdef WIN32
return (r == UV_UNKNOWN);
#endif

This comment has been minimized.

Copy link
@blueyed

blueyed Aug 10, 2019

Owner

This will still log the error for UV_UNKNOWN also.
While that might be good / intentional (until it gets fixed properly), it confused me in AppVeyor logs.

}
return (r == 0 || r == UV_ENOBUFS);
}
Expand Down
5 changes: 2 additions & 3 deletions test/functional/eval/environ_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local clear = helpers.clear
local eq = helpers.eq
local environ = helpers.funcs.environ
local exists = helpers.funcs.exists
local iswin = helpers.iswin

describe('environment variables', function()
it('environ() handles empty env variable', function()
Expand All @@ -12,8 +11,8 @@ describe('environment variables', function()
eq(nil, environ()['DOES_NOT_EXIST'])
end)
it('exists() handles empty env variable', function()
clear({env={EMPTY_VAR=""}}) -- Windows treats this as "undefined".
eq((iswin() and 0 or 1), exists('$EMPTY_VAR'))
clear({env={EMPTY_VAR=""}})
eq(1, exists('$EMPTY_VAR'))
eq(0, exists('$DOES_NOT_EXIST'))
end)
end)

0 comments on commit 278c5d4

Please sign in to comment.