mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	ruby: detect rbenv shims for other versions (#8733)
When rbenv is used for managing Ruby installations, just checking for an
executable called "neovim-ruby-host" is not enough. It has to be run as well.
If it does not return 0, then neovim-ruby-host is merely a shim for another Ruby
installation.
  $ rbenv versions
    2.5.0
  * 2.5.1 (set by /Users/mhi/.rbenv/version)
  $ rbenv whence neovim-ruby-host
  2.5.0
  $ which neovim-ruby-host
  /Users/mhi/.rbenv/shims/neovim-ruby-host
  $ neovim-ruby-host
  rbenv: neovim-ruby-host: command not found
  The `neovim-ruby-host' command exists in these Ruby versions:
    2.5.0
  $ echo $?
  127
Additionally, the detection logic was moved from provider#ruby#Detect() to
s:detect(), because the former is run in the sandbox which forbids calling
system().
			
			
This commit is contained in:
		 Marco Hinz
					Marco Hinz
				
			
				
					committed by
					
						 Justin M. Keyes
						Justin M. Keyes
					
				
			
			
				
	
			
			
			 Justin M. Keyes
						Justin M. Keyes
					
				
			
						parent
						
							c1187d4af0
						
					
				
				
					commit
					d581398779
				
			| @@ -5,11 +5,7 @@ endif | |||||||
| let g:loaded_ruby_provider = 1 | let g:loaded_ruby_provider = 1 | ||||||
|  |  | ||||||
| function! provider#ruby#Detect() abort | function! provider#ruby#Detect() abort | ||||||
|   if exists("g:ruby_host_prog") |   return s:prog | ||||||
|     return g:ruby_host_prog |  | ||||||
|   else |  | ||||||
|     return has('win32') ? exepath('neovim-ruby-host.bat') : exepath('neovim-ruby-host') |  | ||||||
|   end |  | ||||||
| endfunction | endfunction | ||||||
|  |  | ||||||
| function! provider#ruby#Prog() abort | function! provider#ruby#Prog() abort | ||||||
| @@ -47,8 +43,24 @@ function! provider#ruby#Call(method, args) abort | |||||||
|   return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host)) |   return call('rpcrequest', insert(insert(a:args, 'ruby_'.a:method), s:host)) | ||||||
| endfunction | endfunction | ||||||
|  |  | ||||||
|  | function! s:detect() | ||||||
|  |   if exists("g:ruby_host_prog") | ||||||
|  |     return g:ruby_host_prog | ||||||
|  |   elseif has('win32') | ||||||
|  |     return exepath('neovim-ruby-host.bat') | ||||||
|  |   else | ||||||
|  |     let p = exepath('neovim-ruby-host') | ||||||
|  |     if empty(p) | ||||||
|  |       return '' | ||||||
|  |     endif | ||||||
|  |     " neovim-ruby-host could be an rbenv shim for another Ruby version. | ||||||
|  |     call system(p) | ||||||
|  |     return v:shell_error ? '' : p | ||||||
|  |   end | ||||||
|  | endfunction | ||||||
|  |  | ||||||
| let s:err = '' | let s:err = '' | ||||||
| let s:prog = provider#ruby#Detect() | let s:prog = s:detect() | ||||||
| let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb' | let s:plugin_path = expand('<sfile>:p:h') . '/script_host.rb' | ||||||
|  |  | ||||||
| if empty(s:prog) | if empty(s:prog) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user