Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist a .gitkeep file in classmaps directory #51

Closed
markjaquith opened this issue Jun 1, 2020 · 3 comments · Fixed by #52
Closed

Persist a .gitkeep file in classmaps directory #51

markjaquith opened this issue Jun 1, 2020 · 3 comments · Fixed by #52

Comments

@markjaquith
Copy link
Contributor

If your specific Composer/Mozart install doesn't have any classmaps, Mozart will generate an empty classmaps directory, and delete any other files in it. But then you can't check that directory in (because Git only knows about files, not directories). And because you can't check that directory in, a composer install after a git clone will generate a RuntimeException:

[RuntimeException]
Could not scan for classes inside "lib/classmaps/" which does not appear to
be a file nor a folder

Normally I'd solve this by putting a .gitkeep file in my classmaps directory. But Mozart deletes that after every composer update run, so now the working directory has unnecessary changes that I don't want to check in.

I think my ideal solution here would be for Mozart to ignore non-PHP files in the classmaps directory. That'd allow me to persist a .gitkeep, which would ensure that the directory always exists.

@BrianHenryIE
Copy link
Contributor

BrianHenryIE commented Jun 3, 2020

I don't like this.

In most of my use cases classmap_directory is empty. Right now I'm pushing an empty directory to .org svn. I had begun a PR to remove the directory at the end of mozart compose if it is empty.

I think a better solution to your problem, if I'm understanding it correctly, is that Mozart should not delete the classmap_directory or dep_directory themselves, but only delete the subdirectories where it is about to update packages.

Then you can use .gitkeep if you like, without it being deleted. And I could continue my PR to delete the directory if it's empty.

@BrianHenryIE
Copy link
Contributor

Mark, I think my PR #55 addresses your need.

But, TBH, I don't actually understand your real problem. Can you post a composer.json that I can use to reproduce the RuntimeException problem. I admit, and maybe it's because of my [lack of] understanding of PSR-x/classmap, I'm struggling to see where exactly the error is being generated.

@markjaquith
Copy link
Contributor Author

@BrianHenryIE Answered more fully here! #55 (comment)

Here is the minimal composer.json file to reproduce the issue:

{
    "name": "markjaquith/test",
    "autoload" : {
        "classmap": [
            "classes"
        ]
    }
}

Drop that as composer.json in an empty directory (i.e. do NOT create classes subdirectory) and run composer install.

[RuntimeException]
Could not scan for classes inside "classes" which does not appear to be a file nor a folder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants