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

composer require wont work while composer update does. #97

Open
roni-estein opened this issue Sep 23, 2019 · 6 comments
Open

composer require wont work while composer update does. #97

roni-estein opened this issue Sep 23, 2019 · 6 comments

Comments

@roni-estein
Copy link

Amazing project,

I was putting together some new packages, and when using studio, if I run

`studio load /path/to/packages/*' it returns an error with this output

Too many arguments, expected arguments "command" "path".


load <path>

Also, I've noticed in some projects when I create a new project, and then use the following:

studio load path/to/project/project-a this works fine, but if I try something like

composer require roni-estein/package-a I throws this error:


[InvalidArgumentException]
  Could not find a matching version of package roni-estein/laravel-commands. Check the package spelling, your version constraint and that the package is 
available in a stability which matches your minimum-stability (dev).

However, if I add the package to composer.json, and composer update everything works.

Is that an expected behavior? If so, can I contribute a PR to make the README more specific.

Thanks.

@roni-estein
Copy link
Author

re: studio load /path/to/package/*, if I edit studio.json and simply add the line

{
    "version": 2,
    "paths": [
        "/path/to/packages/*"
    ]
}

instead of

{
    "version": 2,
    "paths": [
        "/path/to/packages/package-a",
        "/path/to/packages/package-b",
        "/path/to/packages/package-c",
    ]
}

It all still works, it seem to just be the command to render the * in the first place is throwing the error.

@franzliedke
Copy link
Owner

Hello and thanks for the kind words!

I'd rather implement support for composer require, but for the meantime a PR to explain this limitation in the README would be welcome, too!

The general problem is that since 0.14.0-beta1, we first let Composer do its thing and only then proceed on to replacing installed packages with locally linked ones. That means that we currently do not support packages that are only hosted locally, but not yet available on Packagist. That's a limitation I would love to get rid of, though.

@Arcesilas
Copy link
Contributor

I'm still looking for a way to require a package without defining it in composer.json first. Since I've unsuccessfully tried to hook in command composer require, could it be possible to add a command to studio to require a package from command line?
Something like studio require vendor/package version instead of composer require ....

@imme-emosol
Copy link
Contributor

My recently accepted & merged commit to change the README fixed this issue.

In short; add quotes around the provided path so the shell will not expand the * (asterisk).

@johnorourke
Copy link

Just adding my solution for anyone who wants to use composer require local packages - I skipped using studio for this case, and run composer config repositories.local '{"type":"path","url":"/path/to/composer/module"}', then composer require. Studio's purpose (my understanding at least) is to override the URL used for updating modules that are already available from your existing list of remote repositories, not for loading any local module - composer can already do that.

@roni-estein
Copy link
Author

roni-estein commented Mar 3, 2022

Hey @johnorourke. I'm taking time off coding at the moment, however I got this email on my phone rather late it seems and I can oddly answer it so thought I'd pass on the reasoning for this package, at least for me.

Using a path or VCS repository is fine when you are developing a local asset, however occasionally you are dealing with updating more than one project. And though this shouldn't be an issue, what always seems to happen is on a Friday when everything is finally solved and you are exhausted and it's late and you are about to run home, you deploy because you are an idiot but its critical and you've got robust testing and you know you are in a safe space so you do it. And then then world ends. Because you have a path repository in your composer.json and it 2016 and you don't have that safeguard in place. :) You can fill in the rest of the story.

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

No branches or pull requests

5 participants