`psalm --version` fails on Composer projects without any autoloaders

Open Beginner friendly
#11,149 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
cli

Research direction

Start by tracing the CLI handling for --version and the composer autoloader discovery that produces the reported error. Confirm the change by running psalm --version in a directory with composer.json but no vendor/autoloader.php; it should print the Psalm version without requiring an autoloader.

Written by the indexing model from the issue text.

Description

If I run psalm --version in a directory that contains a composer.json, but without a respective vendor/autoloader.php, Psalm will spit out an error. A workaround seems to be to run psalm --version within a fresh directory. For example:

repo$ psalm --version
Could not find any composer autoloaders in /repo
Add a --root=[your/project/directory] flag to specify a particular project to run Psalm on.
repo$ cd $(mktemp -d)
tmp.YQhKg9ZiiV$ psalm --version
Psalm 5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0

I understand why Psalm can't work without autoloaders, but --version should not be subject to this restriction.

Dominant language
PHP
Stars
5.9k
Forks
708
Avg merge
2d 3h
Merged PRs (30d)
25

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vimeo/psalm

All issues in vimeo/psalm

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.