none-ls fails with "failed to spawn command pmd: EACCESS: permission denied" but command is executable
FedeAbella opened this issue · comments
Federico Abella commented
FAQ
- I have checked the FAQ and it didn't resolve my problem.
Issues
- I have checked existing issues and there are no issues with the same problem.
Neovim Version
0.9.5
Dev Version?
- I am using a stable Neovim release version, or if I am using a dev version of Neovim I have confirmed that my issue is reproducible on a stable version.
Operating System
Ubuntu 23.10
Minimal Config
-- this template is borrowed from nvim-lspconfig
local on_windows = vim.loop.os_uname().version:match("Windows")
local function join_paths(...)
local path_sep = on_windows and "\\" or "/"
local result = table.concat({ ... }, path_sep)
return result
end
vim.g.loaded_remote_plugins = ""
vim.cmd([[set runtimepath=$VIMRUNTIME]])
local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"
vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))
local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")
vim.filetype = on
vim.filetype.add({
extension = {
cls = 'apex',
apex = 'apex',
trigger = 'apex',
soql = 'soql',
sosl = 'sosl',
}
})
local null_ls_config = function()
local null_ls = require("null-ls")
-- add only what you need to reproduce your issue
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.pmd.with({
extra_args = {
'--rulesets',
'~/.local/bin/pmd/rulesets/apex.xml'
},
filetypes = { 'apex' }
})
},
debug = true,
})
end
local function load_plugins()
-- only add other plugins if they are necessary to reproduce the issue
require("packer").startup({
{
"wbthomason/packer.nvim",
{
"jose-elias-alvarez/null-ls.nvim",
requires = { "nvim-lua/plenary.nvim" },
config = null_ls_config,
},
},
config = {
package_root = package_root,
compile_path = compile_path,
},
})
end
if vim.fn.isdirectory(install_path) == 0 then
vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
load_plugins()
require("packer").sync()
else
load_plugins()
require("packer").sync()
end
Steps to Reproduce
- Create
pmd.sh
(https://pastebin.com/mj1R5YZn) - Add
pmd.sh
to PATH, and aliaspmd
command to id
if [ -d $HOME/.local/scripts ]; then
PATH=$HOME/.local/scripts:$PATH
[[ ! -f $HOME/.local/scripts/pmd.sh ]] || alias pmd='~/.local/scripts/pmd.sh'
fi
- Make
pmd.sh
executable:
- Add an apex class file to a directory (sample: https://pastebin.com/NtYH3Bdn)
- Ensure
pmd
can be run as a command from the command line using the arguments passed by null-ls:
- Open the apex class file inside neovim, I get this error:
Reproducibility Check
- I confirm that my minimal config is based on the
minimal_init.lua
template and that my issue is reproducible by runningnvim --clean -u minimal_init.lua
and following the steps above.
Expected Behavior
PMD is run for the file and results show up
Actual Behavior
Error message [null-ls] failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: failed to spawn command pmd: EACCES: permission denied
is shown
Debug Log
[TRACE Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/client.lua:114: starting null-ls client
[TRACE Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/rpc.lua:106: received LSP request for method initialize
[TRACE Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/rpc.lua:131: received LSP notification for method initialized
[TRACE Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/rpc.lua:131: received LSP notification for method textDocument/didOpen
[TRACE Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN
[DEBUG Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/helpers/generator_factory.lua:329: spawning command "pmd" at /home/fede/Programming/Salesforce/trigger-framework with args { "--format", "json", "--dir", "/home/fede/Programming/Salesforce/trigger-framework", "--rulesets", "~/.local/bin/pmd/rulesets/apex.xml" }
[WARN Tue 13 Feb 2024 23:48:24 -03] /home/fede/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ....local/share/nvim/lazy/none-ls.nvim/lua/null-ls/loop.lua:165: failed to spawn command pmd: EACCES: permission denied
Help
No
Implementation Help
No response
Requirements
- I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
Zephyr Lykos commented
Resolving the alias is done within your shell. none-ls only exec the target binary directly instead of starting a subshell.
Federico Abella commented
Ah, got it. Thanks for clarifying that! Got it working like a charm 😁