preservim / vimux

easily interact with tmux from vim
MIT License
2.19k stars 158 forks source link

Unknown function: environ #208

Open endoped opened 2 years ago

endoped commented 2 years ago

I'm getting this error on vim v8.1, tmux v2.8 after pulling in the change from https://github.com/preservim/vimux/pull/204

 Error detected while processing function VimuxPromptCommand[10]..VimuxRunCommand[2]..VimuxOpenRunner[1]..<SNR>23_nearestIndex[3]..VimuxTmux:
line    5:
E117: Unknown function: environ
E116: Invalid arguments for function has_key(environ(), 'TMUX')

I did this to fix it. Not sure if this is something you want to look into or if it's just an issue with my environment that I don't care to take the time to fix.

index 0737d74..7e3d04d 100644
--- a/plugin/vimux.vim
+++ b/plugin/vimux.vim
@@ -189,7 +189,7 @@ function! VimuxTmux(arguments) abort
   if VimuxOption('VimuxDebug')
     echom VimuxOption('VimuxTmuxCommand').' '.a:arguments
   endif
-  if has_key(environ(), 'TMUX')
+  if exists('$TMUX')
     return system(VimuxOption('VimuxTmuxCommand').' '.a:arguments)
   else
     throw 'Aborting, because not inside tmux session.'
alerque commented 2 years ago

The environ() function was added in VIM 8.1.1305 back in 2019. It also exists in NeoVIM. I'm not too keen on supporting old versions, but your alternative for this simple task probably wouldn't hurt in this case as long as current VIM & NeoVIM versions support it the same way. I'd be happy to review a PR if you submit this change.

Also note your tmux is obscenely outdated. I'm not 100% sure 2.x releases are even supported by this plugin. If you run into more trouble consider updating to something from the last few years.