bug: vim.fn.system fails to execute commands in nushell · Issue #471 · nvim-java/nvim-java · GitHub
Skip to content

bug: vim.fn.system fails to execute commands in nushell #471

Description

@Solaestas

Did you check docs and existing issues?

  • I have read all the plugin docs
  • I have searched the existing issues
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.11.5

Operating system/version

Windows/25H2

Describe the bug

When using Nushell as the system shell, the downloader and extractor modules in nvim-java fail to work. The issue stems from using vim.fn.system(cmd) to execute commands, which passes the entire command string to the system shell for parsing. In non-traditional shells like Nushell, this causes argument parsing errors or command execution failures.

Steps To Reproduce

  1. Set nushell as the default nvim shell
  2. Install and load nvim-java

Expected Behavior

The plugin should work correctly in nushell. Using Neovim 0.10+'s vim.system() API with argument arrays would avoid shell parsing issues.

example

	local pwsh_cmd = string.format(
		'iwr -TimeoutSec %d -UseBasicParsing -Method "GET" -Uri %q -OutFile %q;',
		self.timeout,
		self.url,
		self.dest
	)

	local cmd = string.format(
		-- luacheck: ignore
		"%s -NoProfile -NonInteractive -Command \"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; %s\"",
		pwsh,
		pwsh_cmd
	)
	log.debug('PowerShell command:', cmd)

	local result = vim.fn.system(cmd)
	local result = vim.system({
		"pwsh",
		"-NoProfile",
		"-NonInteractive",
		"-Command",
		"$ProgressPreference = 'SilentlyContinue';",
		"$ErrorActionPreference = 'Stop';",
		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;",
		"iwr",
		"-TimeoutSec",
		tostring(self.timeout),
		"-UseBasicParsing",
		"-Method GET",
		"-Uri",
		self.url,
		"-OutFile",
		self.dest,
	}):wait()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions