Skip to content

yamllint: Failed to open stream: No such file or directory #1215

@loopy3025

Description

@loopy3025

Environment: Drupal 11
grumphp version: 2.20
Affected checks: yamllint and git pre-commit
grumphp.yml:

grumphp:
  tasks:
    composer: ~
    phplint: ~ 
    yamllint:
      ignore_patterns:
        - '/node_modules/'
    phpcs:
      standard: "phpcs.xml.dist"
    securitychecker_composeraudit:
      abandoned: 'report'
    git_commit_message: 
      enforce_no_subject_trailing_period: false
      matchers:
        Must use the following format (jira project, dash, jira number, space, commit message): "/(\\w+)-\\d+:\\s+.+/"
      max_subject_width: 120
      max_body_width: 255

We've been getting intermittent issues where grumphp has been failing on yamllint during its pre-commit hook.

SplFileInfo::openFile(:100644 100644 deff8132bc 02a1e5dd34 M config/default/core.extension.yml): Failed to open stream: No such file or directory

This file is one of the files I have staged to commit in git. It is clearly there. When I simply run the grumphp command, there is no error. It's only angry when I'm running a git commit message.

Here is the .git/hooks/pre-commit file in that project:

#!/bin/sh

#
# Run the hook command.
# Note: this will be replaced by the real command during copy.
#

# Fetch the GIT diff and format it as command input:
DIFF=$(git -c diff.mnemonicprefix=false -c diff.noprefix=false --no-pager diff -r -p -m -M --full-index --no-color --staged | cat)

# Grumphp env vars

export GRUMPHP_GIT_WORKING_DIR="$(git rev-parse --show-toplevel)"

# Run GrumPHP
(cd "./" && printf "%s\n" "${DIFF}" | exec 'vendor/bin/grumphp' 'git:pre-commit' '--skip-success-output')

This is the same that gets regenerated when I delete the file and I run grumphp git:init. For now I am running with --no-verify but I'm not sure what happened here. It's fairly intermittent and I am wondering if it has something to do with unencoded file names; perhaps a certain character. Not sure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions