Skip to content

pcall returning true for a non existing plugin or module #512

@Antony-AXS

Description

@Antony-AXS

Description

When using pcall to safely load a Lua module via require, the call unexpectedly returns true and a non-nil result (often true), even if the module does not exist in the filesystem. This behavior leads to false positives, making it appear as though the module was loaded successfully.

This issue seems to occur because pcall is returning true for the protected call, even when require fails to find the module. As a result, pcall is unable to reliably distinguish between a successfully loaded module and a missing or unavailable module, leading to subtle bugs when relying on pcall(require, ...) as a check for module existence.

To Reproduce
Steps to reproduce the behavior:

  1. type pcall(require("non-existing-package")) in the neovim command line you will get a response like ''true, true"
  2. Since 'strive' is not installed, the error ends up occurring.
Screencast.from.30-04-25.12.18.18.PM.IST.webm

Screenshots
line number 136 is where the error happens
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions