Add command to clear composer cache #941

Closed
mattfarina opened this Issue Jul 23, 2012 · 62 comments

Comments

Projects
None yet
@mattfarina

I've had issues with caching in composer. It would be nice to have a command to manually clear it.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Aug 10, 2012

Member

Could you be more specific about the issues? I'd rather fix the issues than add more cruft.

Member

Seldaek commented Aug 10, 2012

Could you be more specific about the issues? I'd rather fix the issues than add more cruft.

@mattfarina

This comment has been minimized.

Show comment
Hide comment
@mattfarina

mattfarina Aug 10, 2012

@Seldaek it appears composer is keeping a cache of stuff at ~/.composer. When I posted this issue I thought my problem was stale items in the cache causing problems. It turns out my issues lie elsewhere.

In the composer docs I didn't see anything about a cache. I only stumbled upon it. Is the existence of the cache and the ability to delete what's in the cache a possibility that can be added?

@Seldaek it appears composer is keeping a cache of stuff at ~/.composer. When I posted this issue I thought my problem was stale items in the cache causing problems. It turns out my issues lie elsewhere.

In the composer docs I didn't see anything about a cache. I only stumbled upon it. Is the existence of the cache and the ability to delete what's in the cache a possibility that can be added?

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Aug 10, 2012

Member

The cache stuff is not documented much (at all?) because mostly nobody cares, it's just there and it makes stuff faster but you shouldn't have to bother. Why would you need to clear it?

Member

Seldaek commented Aug 10, 2012

The cache stuff is not documented much (at all?) because mostly nobody cares, it's just there and it makes stuff faster but you shouldn't have to bother. Why would you need to clear it?

@Djuki

This comment has been minimized.

Show comment
Hide comment
@Djuki

Djuki Aug 10, 2012

It's because I constantly get this error while i am trying to update packages via composer

"http://packagist.org could not be loaded, package information was loaded from the local cache and may be out of date"

Then i removed .composer/cache folder

After I remove folder I updated my packages. It looks like my cache is not update whit fresh data at all. So, there is some kind of bug.

Djuki commented Aug 10, 2012

It's because I constantly get this error while i am trying to update packages via composer

"http://packagist.org could not be loaded, package information was loaded from the local cache and may be out of date"

Then i removed .composer/cache folder

After I remove folder I updated my packages. It looks like my cache is not update whit fresh data at all. So, there is some kind of bug.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Aug 11, 2012

Member

That message just says you couldn't reach packagist.org for some reason and so it used the data from the cache, but when it can reach packagist it should update it alright. I don't think there is a bug there.

Member

Seldaek commented Aug 11, 2012

That message just says you couldn't reach packagist.org for some reason and so it used the data from the cache, but when it can reach packagist it should update it alright. I don't think there is a bug there.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 5, 2012

Hmm....so there IS a cache in composer?! Can`t find any ~/.composer though. But It maybe related to my problem:

Removing dependecies of a package in a company internal git repository doesn`t seem to have an effect. Composer still thinks the package requires some others. I have removed the 'require' section of the package in composer.json and commited the changed file to git. Howto force composer to re-read this information?

ghost commented Sep 5, 2012

Hmm....so there IS a cache in composer?! Can`t find any ~/.composer though. But It maybe related to my problem:

Removing dependecies of a package in a company internal git repository doesn`t seem to have an effect. Composer still thinks the package requires some others. I have removed the 'require' section of the package in composer.json and commited the changed file to git. Howto force composer to re-read this information?

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Sep 5, 2012

Member

@sigurros if you're on windows it's not in ~/.composer, see https://getcomposer.org/doc/03-cli.md#composer-home - that said the cache is purely for failover and performance, it does not do any TTL-based caching, so if anything changes it should not prevent you from getting the new information.

Member

Seldaek commented Sep 5, 2012

@sigurros if you're on windows it's not in ~/.composer, see https://getcomposer.org/doc/03-cli.md#composer-home - that said the cache is purely for failover and performance, it does not do any TTL-based caching, so if anything changes it should not prevent you from getting the new information.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 6, 2012

@Seldaek Thanks for the hint. I will recheck what information is in the cache.

ghost commented Sep 6, 2012

@Seldaek Thanks for the hint. I will recheck what information is in the cache.

@jrgns

This comment has been minimized.

Show comment
Hide comment
@jrgns

jrgns Sep 10, 2012

I found that if I did a composer action, and then later did something like

sudo -u www-data composer update

I would get the error, purely because the cache is unwritable for www-data, not because packagist.org could not be loaded. So the bug can be construed as that the error message doesn't give you the relevant information - file permissions on the cache.

jrgns commented Sep 10, 2012

I found that if I did a composer action, and then later did something like

sudo -u www-data composer update

I would get the error, purely because the cache is unwritable for www-data, not because packagist.org could not be loaded. So the bug can be construed as that the error message doesn't give you the relevant information - file permissions on the cache.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Sep 10, 2012

Member

But if you do that, the cache dir should be in www-data's home dir (typically /var/www) and not in your home dir (/home/foo) or is it inheriting your env settings even when you sudo -u? Anyway I agree the error message should be fixed.

Member

Seldaek commented Sep 10, 2012

But if you do that, the cache dir should be in www-data's home dir (typically /var/www) and not in your home dir (/home/foo) or is it inheriting your env settings even when you sudo -u? Anyway I agree the error message should be fixed.

@jrgns

This comment has been minimized.

Show comment
Hide comment
@jrgns

jrgns Sep 10, 2012

I think, and it looks like, it's inheriting the current user's env settings when doing sudo

jrgns commented Sep 10, 2012

I think, and it looks like, it's inheriting the current user's env settings when doing sudo

@mente

This comment has been minimized.

Show comment
Hide comment
@mente

mente Sep 25, 2012

Any updates on it? This problem brings adds problems with permissions for cache files

mente commented Sep 25, 2012

Any updates on it? This problem brings adds problems with permissions for cache files

@mente

This comment has been minimized.

Show comment
Hide comment
@mente

mente Sep 25, 2012

Or is there an option to force using different cache dir?

mente commented Sep 25, 2012

Or is there an option to force using different cache dir?

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Sep 25, 2012

Member

I'm not sure what we can do about this, it seems to be more a problem of sudo than composer. Anyway you can use COMPOSER_HOME=/var/www or whatever path to force it to go somewhere else, or you could add www-data to your user's group so that it has access to your cache dir..

Member

Seldaek commented Sep 25, 2012

I'm not sure what we can do about this, it seems to be more a problem of sudo than composer. Anyway you can use COMPOSER_HOME=/var/www or whatever path to force it to go somewhere else, or you could add www-data to your user's group so that it has access to your cache dir..

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Sep 25, 2012

Contributor

@jrgns add the -H option when running sudo so that it sets the HOME to the one of the target user instead of keeping the HOME of yourself.

Contributor

stof commented Sep 25, 2012

@jrgns add the -H option when running sudo so that it sets the HOME to the one of the target user instead of keeping the HOME of yourself.

@jrgns

This comment has been minimized.

Show comment
Hide comment
@jrgns

jrgns Sep 26, 2012

@stof Shot, thanx.

jrgns commented Sep 26, 2012

@stof Shot, thanx.

@ddebree

This comment has been minimized.

Show comment
Hide comment
@ddebree

ddebree Dec 5, 2012

I agree that this should be added. I had a problem where I downloaded a corrupted zip file (that composer then cached) and there was no way for me to remove it besides manually wiping out the cache folder. Would have been a lot easier if there was a clear cache command.
See issue #1242

ddebree commented Dec 5, 2012

I agree that this should be added. I had a problem where I downloaded a corrupted zip file (that composer then cached) and there was no way for me to remove it besides manually wiping out the cache folder. Would have been a lot easier if there was a clear cache command.
See issue #1242

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Dec 5, 2012

Member

@ddebree that's just a cache bug, not a good case for a cache clear command. I fixed the bug by the way.

Member

Seldaek commented Dec 5, 2012

@ddebree that's just a cache bug, not a good case for a cache clear command. I fixed the bug by the way.

@ddebree

This comment has been minimized.

Show comment
Hide comment
@ddebree

ddebree Dec 5, 2012

@Seldaek Awesome. This problem had me scratching my head for quite a few days!

ddebree commented Dec 5, 2012

@Seldaek Awesome. This problem had me scratching my head for quite a few days!

@till

This comment has been minimized.

Show comment
Hide comment
@till

till Mar 7, 2013

Contributor

Just adding this here: sudo -u www-data -i ./composer.phar whatever — should work.

Contributor

till commented Mar 7, 2013

Just adding this here: sudo -u www-data -i ./composer.phar whatever — should work.

@till

This comment has been minimized.

Show comment
Hide comment
@till

till Mar 7, 2013

Contributor

Btw, the cache command should be available to be able to manage this via composer vs. telling people to rm -rf ~/.composer/cache*. It could also display usage on the disk and when the cache was created (e.g. to hint that it's possibly stale).

Something like:

$ ./composer cache [usage]
Cache: X MB
Github Cache: X MB
Cache created/last updated: yyyy-mm-dd HH:ii:ss 
$ ./composer cache clear
...
Contributor

till commented Mar 7, 2013

Btw, the cache command should be available to be able to manage this via composer vs. telling people to rm -rf ~/.composer/cache*. It could also display usage on the disk and when the cache was created (e.g. to hint that it's possibly stale).

Something like:

$ ./composer cache [usage]
Cache: X MB
Github Cache: X MB
Cache created/last updated: yyyy-mm-dd HH:ii:ss 
$ ./composer cache clear
...
@philjohn

This comment has been minimized.

Show comment
Hide comment
@philjohn

philjohn Mar 27, 2013

We've run into an issue with the cache today. A colleague couldn't install the dependencies for something, but it was find on my machine - because it was loading from cache.

Once I realised this, I removed the contents and saw the issue and was able to fix it - but it wasted a good 10-20 minutes of time tracking it down.

We've run into an issue with the cache today. A colleague couldn't install the dependencies for something, but it was find on my machine - because it was loading from cache.

Once I realised this, I removed the contents and saw the issue and was able to fix it - but it wasted a good 10-20 minutes of time tracking it down.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Mar 27, 2013

Member

@philjohn what was preventing them from installing if not a network issue? That's all the cache should "shield" you from.

Member

Seldaek commented Mar 27, 2013

@philjohn what was preventing them from installing if not a network issue? That's all the cache should "shield" you from.

@philjohn

This comment has been minimized.

Show comment
Hide comment
@philjohn

philjohn Mar 27, 2013

Hi,

The package in question is endroid/qrcode (via packagist) - specifying 1.0.* as the required version in composer.json yields (when the old version is no longer cached):

Could not fetch https://api.github.com/repos/endroid/QrCode/zipball/v1.0, enter your GitHub credentials to access private repos
The credentials will be swapped for an OAuth token stored in /home/USERNAME/.composer/config.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username:

Regards,

Phil.

Hi,

The package in question is endroid/qrcode (via packagist) - specifying 1.0.* as the required version in composer.json yields (when the old version is no longer cached):

Could not fetch https://api.github.com/repos/endroid/QrCode/zipball/v1.0, enter your GitHub credentials to access private repos
The credentials will be swapped for an OAuth token stored in /home/USERNAME/.composer/config.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username:

Regards,

Phil.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Mar 27, 2013

Member

Yeah ok you got unlucky on that one. The maintainer of that package thought it was fun to delete tags. Not cool. Anyway I updated packagist now so this package doesn't break for others in the future.

Member

Seldaek commented Mar 27, 2013

Yeah ok you got unlucky on that one. The maintainer of that package thought it was fun to delete tags. Not cool. Anyway I updated packagist now so this package doesn't break for others in the future.

@srcspider

This comment has been minimized.

Show comment
Hide comment
@srcspider

srcspider Sep 2, 2013

Encountered an issue today where when running composer with instructions to retrieve dist would constantly install the old package over and over from cache. I know it's installing the old package since I'm the one maintaining the package in question. I did Force Reload in Packagist to no avail.

Somehow I'm assuming composer is encountering an error and falling back to cache, or there has been some change in behavior recently (since I have it in a script that auto-updates composer when it runs).

Since I was aware of the change and issues with the change in my package and the change was one line this was only a minor annoyance but I can see how this can be a real headache at a time where you depend on composer retrieving the right version (to the commit) and it just fails to do so.

I believe the message "from cache" is also error prone. It should say instead "retrieved [1.0.0] from cache" or "retrieved [asdf325h] from cache" and so on. And if there's any connection issue, etc, it should fail if not explicitly given permission to fallback to cache.

Encountered an issue today where when running composer with instructions to retrieve dist would constantly install the old package over and over from cache. I know it's installing the old package since I'm the one maintaining the package in question. I did Force Reload in Packagist to no avail.

Somehow I'm assuming composer is encountering an error and falling back to cache, or there has been some change in behavior recently (since I have it in a script that auto-updates composer when it runs).

Since I was aware of the change and issues with the change in my package and the change was one line this was only a minor annoyance but I can see how this can be a real headache at a time where you depend on composer retrieving the right version (to the commit) and it just fails to do so.

I believe the message "from cache" is also error prone. It should say instead "retrieved [1.0.0] from cache" or "retrieved [asdf325h] from cache" and so on. And if there's any connection issue, etc, it should fail if not explicitly given permission to fallback to cache.

@Petah

This comment has been minimized.

Show comment
Hide comment
@Petah

Petah Jan 14, 2014

Contributor

Would be nice to be able to clear it. In my case I am struggling for space on a server and the Composer cache is half a GB.

Contributor

Petah commented Jan 14, 2014

Would be nice to be able to clear it. In my case I am struggling for space on a server and the Composer cache is half a GB.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Jan 14, 2014

Member

You can safely rm -rf ~/.composer/cache, it will rebuild as needed.

Member

Seldaek commented Jan 14, 2014

You can safely rm -rf ~/.composer/cache, it will rebuild as needed.

@shavyg2

This comment has been minimized.

Show comment
Hide comment
@shavyg2

shavyg2 Jan 31, 2014

Where is the cache located on windows. This should be a command tho. It's a band-aid but let's not forget the entire world uses band-aid because accidents happen. I'm bleeding over here.... :'(

shavyg2 commented Jan 31, 2014

Where is the cache located on windows. This should be a command tho. It's a band-aid but let's not forget the entire world uses band-aid because accidents happen. I'm bleeding over here.... :'(

@Petah

This comment has been minimized.

Show comment
Hide comment
@Petah

Petah Jan 31, 2014

Contributor

@shavyg2 normally c:\users\YOU\.composer\cache but that is dependant on your setup. Hence why a command would be nice.

Contributor

Petah commented Jan 31, 2014

@shavyg2 normally c:\users\YOU\.composer\cache but that is dependant on your setup. Hence why a command would be nice.

@Seldaek

This comment has been minimized.

Show comment
Hide comment
@Seldaek

Seldaek Feb 5, 2014

Member

composer config cache-dir will show you the effective cache dir.

Member

Seldaek commented Feb 5, 2014

composer config cache-dir will show you the effective cache dir.

@codebyray

This comment has been minimized.

Show comment
Hide comment
@codebyray

codebyray Feb 10, 2014

Cache on windows 7 is : C:\Users\YOU\AppData\Local\Composer\files.

Cache on windows 7 is : C:\Users\YOU\AppData\Local\Composer\files.

@rtconner

This comment has been minimized.

Show comment
Hide comment
@rtconner

rtconner Mar 10, 2014

Yes, a command to just delete the cache folder would make my life happier.

Yes, a command to just delete the cache folder would make my life happier.

@jakoch

This comment has been minimized.

Show comment
Hide comment
@jakoch

jakoch Mar 27, 2014

Contributor

Different windows versions, different storage paths. Would save some time...
+1 for composer flush-cache

Contributor

jakoch commented Mar 27, 2014

Different windows versions, different storage paths. Would save some time...
+1 for composer flush-cache

@spidgorny

This comment has been minimized.

Show comment
Hide comment
@spidgorny

spidgorny Mar 31, 2014

+1 or composer clearcache and composer clearcache twig/twig

+1 or composer clearcache and composer clearcache twig/twig

@TomasVotruba

This comment has been minimized.

Show comment
Hide comment
@TomasVotruba

TomasVotruba Apr 14, 2014

Contributor

+1 for some command

Till then a workaround. In Linux you can delete cache like this:

$ composer config cache-dir
somedir
$ cd somedir
$ sudo rm -rf *
Contributor

TomasVotruba commented Apr 14, 2014

+1 for some command

Till then a workaround. In Linux you can delete cache like this:

$ composer config cache-dir
somedir
$ cd somedir
$ sudo rm -rf *
@Iarwa1n

This comment has been minimized.

Show comment
Hide comment
@Iarwa1n

Iarwa1n Apr 28, 2014

Also +1 for a command and a parameter like composer install --ignore-cache.
My use case: another developer reported that one package required a login and I could not test this because I had the package in my cache already.

Iarwa1n commented Apr 28, 2014

Also +1 for a command and a parameter like composer install --ignore-cache.
My use case: another developer reported that one package required a login and I could not test this because I had the package in my cache already.

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Apr 28, 2014

Contributor

COMPOSER_CACHE_DIR=/dev/null composer install should do the trick

Contributor

stof commented Apr 28, 2014

COMPOSER_CACHE_DIR=/dev/null composer install should do the trick

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jun 3, 2014

I also have a cache problem : when I use composer update , the repo checks out correctly, but if I make another commit on the repo and then use composer update again, even if Packagist is up to date, even if I change options and use like --prefer-dist or --prefer-source , the repo will not checkout and the new commit will not be synchronized until a long time which I actually do not want to calculate nor estimate.

You can safely rm -rf ~/.composer/cache, it will rebuild as needed.

You can even say that, but not when people use cronjobs or different envs or other things. My case : I use only one composer for all my SF2 apps, except 1, and as the Windows user is the same, the cache is the same, and it seems to be totally messed up whenever updates are made on Packagist and when I run composer update on any of my apps.

Really, the cache dir is set up directly in composer, so any command would be easy to make, and nice for us to clear the cache directly from composer, because any user running a "working" composer will have read/write access to the cache, so clearing the cache is not such a hard feature to add to composer.

Really, Composer is such an awesome tool, but one feature is missing, and it is present in many other dependencies managers...

I also have a cache problem : when I use composer update , the repo checks out correctly, but if I make another commit on the repo and then use composer update again, even if Packagist is up to date, even if I change options and use like --prefer-dist or --prefer-source , the repo will not checkout and the new commit will not be synchronized until a long time which I actually do not want to calculate nor estimate.

You can safely rm -rf ~/.composer/cache, it will rebuild as needed.

You can even say that, but not when people use cronjobs or different envs or other things. My case : I use only one composer for all my SF2 apps, except 1, and as the Windows user is the same, the cache is the same, and it seems to be totally messed up whenever updates are made on Packagist and when I run composer update on any of my apps.

Really, the cache dir is set up directly in composer, so any command would be easy to make, and nice for us to clear the cache directly from composer, because any user running a "working" composer will have read/write access to the cache, so clearing the cache is not such a hard feature to add to composer.

Really, Composer is such an awesome tool, but one feature is missing, and it is present in many other dependencies managers...

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 3, 2014

Contributor

@Pierstoval The json files loaded by composer on Packagist are not generated on the fly (it is impossible as it would be far too slow). They are static files dumped by a cron. So even through the packagist web interface shows you the new commit because the DB has been updated, there is a delay before composer can see it (the delay can be up to 10minutes if you are not lucky and the cron ran just before your update came in)

Your issue is not the composer cache

Contributor

stof commented Jun 3, 2014

@Pierstoval The json files loaded by composer on Packagist are not generated on the fly (it is impossible as it would be far too slow). They are static files dumped by a cron. So even through the packagist web interface shows you the new commit because the DB has been updated, there is a delay before composer can see it (the delay can be up to 10minutes if you are not lucky and the cron ran just before your update came in)

Your issue is not the composer cache

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jun 3, 2014

Ok, then it solves one problem, but still, it seems for many other developers that a "clearcache" function would be great :)

Ok, then it solves one problem, but still, it seems for many other developers that a "clearcache" function would be great :)

@stof

This comment has been minimized.

Show comment
Hide comment
@stof

stof Jun 3, 2014

Contributor

@Pierstoval this is very low priority, because unless composer is buggy (which should then be fixed with a high priority), you should never need to clear you cache (except to save some space on your filesystem). The cache layer is meant to be transparent to the user.

Contributor

stof commented Jun 3, 2014

@Pierstoval this is very low priority, because unless composer is buggy (which should then be fixed with a high priority), you should never need to clear you cache (except to save some space on your filesystem). The cache layer is meant to be transparent to the user.

@Petah

This comment has been minimized.

Show comment
Hide comment
@Petah

Petah Jun 4, 2014

Contributor

As per my previous comment saving space was exactly why I needed it:

#941 (comment)

Anyway I have made a simple command to achieve this, hopefully it can get merged :)

Contributor

Petah commented Jun 4, 2014

As per my previous comment saving space was exactly why I needed it:

#941 (comment)

Anyway I have made a simple command to achieve this, hopefully it can get merged :)

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jun 4, 2014

Really nice, hope it will :)

Really nice, hope it will :)

@agwidarsito

This comment has been minimized.

Show comment
Hide comment
@agwidarsito

agwidarsito Jun 4, 2014

Fantastic! :) This was a pain before...

Fantastic! :) This was a pain before...

@SDKiller

This comment has been minimized.

Show comment
Hide comment
@SDKiller

SDKiller Jul 13, 2014

you should never need to clear you cache

What is the reason to keep in composer cache ALL downloads?
I just looked at my cache - for each package dozens of files for the whole time I use composer are kept!

+1 for the built-in feature

you should never need to clear you cache

What is the reason to keep in composer cache ALL downloads?
I just looked at my cache - for each package dozens of files for the whole time I use composer are kept!

+1 for the built-in feature

@SDKiller SDKiller referenced this issue in yiisoft/yii2 Jul 15, 2014

Closed

Can't install yiisoft/yii2-faker #4306

@SDKiller

This comment has been minimized.

Show comment
Hide comment
@SDKiller

SDKiller Jul 15, 2014

Guys, start thinkinking of the men at the end!
if I have 200 MiB composer cache - it's a problem.
If I cannot install extension - it's a problem.
Where you keep you HDD - in cloud?
If there is no answer on pull request #3034 from April - it's a problem!

Guys, start thinkinking of the men at the end!
if I have 200 MiB composer cache - it's a problem.
If I cannot install extension - it's a problem.
Where you keep you HDD - in cloud?
If there is no answer on pull request #3034 from April - it's a problem!

@grEvenX

This comment has been minimized.

Show comment
Hide comment
@grEvenX

grEvenX Jul 18, 2014

@SDKiller why not just use COMPOSER_CACHE_DIR=/dev/null composer install as @stof suggested earlier?

grEvenX commented Jul 18, 2014

@SDKiller why not just use COMPOSER_CACHE_DIR=/dev/null composer install as @stof suggested earlier?

@Petah

This comment has been minimized.

Show comment
Hide comment
@Petah

Petah Jul 18, 2014

Contributor

@grEvenX because composer clear-cache is much more clearer and precise, and has already been merged and is available.

This issue should be closed.

composer clear-cache

👍

Contributor

Petah commented Jul 18, 2014

@grEvenX because composer clear-cache is much more clearer and precise, and has already been merged and is available.

This issue should be closed.

composer clear-cache

👍

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Jul 18, 2014

Thanks a lot for merging this functionality :)

👍

Thanks a lot for merging this functionality :)

👍

@craighooghiem craighooghiem referenced this issue in Zizaco/confide Jul 20, 2014

Merged

Removed branch alias #320

@M1ke

This comment has been minimized.

Show comment
Hide comment
@M1ke

M1ke Aug 13, 2014

Now that this is available shouldn't the issue be closed? Just thinking I read down the whole thread because it was open and thus assumed the function wasn't available yet, whereas it's documented in the 2nd to last post. Thanks for merging too!

M1ke commented Aug 13, 2014

Now that this is available shouldn't the issue be closed? Just thinking I read down the whole thread because it was open and thus assumed the function wasn't available yet, whereas it's documented in the 2nd to last post. Thanks for merging too!

@Petah

This comment has been minimized.

Show comment
Hide comment
@Petah

Petah Aug 13, 2014

Contributor

@M1ke There is still an outstanding pull request for this: #3175

Contributor

Petah commented Aug 13, 2014

@M1ke There is still an outstanding pull request for this: #3175

@ioleo

This comment has been minimized.

Show comment
Hide comment
@ioleo

ioleo Sep 13, 2014

👍 for composer clear-cache (clear all) and composer clear-cache <package-name1> <package-name2> <etc..> (clear cache for specified packages)

ioleo commented Sep 13, 2014

👍 for composer clear-cache (clear all) and composer clear-cache <package-name1> <package-name2> <etc..> (clear cache for specified packages)

@Seldaek Seldaek closed this Sep 18, 2014

@ik-j

This comment has been minimized.

Show comment
Hide comment
@ik-j

ik-j Nov 28, 2014

@loostro thanks I ws looking for this command :)

ik-j commented Nov 28, 2014

@loostro thanks I ws looking for this command :)

@ioleo

This comment has been minimized.

Show comment
Hide comment

ioleo commented Dec 12, 2014

@ik-j thank @Petah for #3034 and #3175

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 2, 2015

Hi all.
I think there is still some bug in composer int
I experience that after first time i used comoser init and then rename composer.json to composer.json.old I can't generate fresh composer.json because :

Package name (/) [Bartek/a]: bartek/aaa
Description []: asddf
Author: zzz xxx qww@dfdf.pl
Invalid author string. Must be in the format: John Smith john@example.com

But what is interesting after clear-cache and change directory I could generate new composer.json without any problems.
I saw that someone suggesting mention about privileges in UNIX OS but currently I'm developing under Windows platform so I don't expect any special issue about privileges.
I simple tried uninstall and install composer again but this doesn't solve the problem.
I hope my symptoms could help little to generally solve this problem at all.

Additional :

D:\symfony\a>composer clear-cache
Clearing cache (cache-dir): C:\Users\Bartek\AppData\Local\Composer
Cache directory does not exist (cache-files-dir):

Sorry if i put symptoms in wrong place ... I'm new.

ghost commented Feb 2, 2015

Hi all.
I think there is still some bug in composer int
I experience that after first time i used comoser init and then rename composer.json to composer.json.old I can't generate fresh composer.json because :

Package name (/) [Bartek/a]: bartek/aaa
Description []: asddf
Author: zzz xxx qww@dfdf.pl
Invalid author string. Must be in the format: John Smith john@example.com

But what is interesting after clear-cache and change directory I could generate new composer.json without any problems.
I saw that someone suggesting mention about privileges in UNIX OS but currently I'm developing under Windows platform so I don't expect any special issue about privileges.
I simple tried uninstall and install composer again but this doesn't solve the problem.
I hope my symptoms could help little to generally solve this problem at all.

Additional :

D:\symfony\a>composer clear-cache
Clearing cache (cache-dir): C:\Users\Bartek\AppData\Local\Composer
Cache directory does not exist (cache-files-dir):

Sorry if i put symptoms in wrong place ... I'm new.

@Pierstoval

This comment has been minimized.

Show comment
Hide comment
@Pierstoval

Pierstoval Feb 2, 2015

I had some issues of this kind with my Composer, as I'm developing on the E: drive, and composer cache is on the C: drive. What I did to fix that is to create a symlink in C: in the composer directory, and this link targets a directory on E:, and it works like a charm, but I don't know if it'll fix your issue that is maybe more related to a package :/

I had some issues of this kind with my Composer, as I'm developing on the E: drive, and composer cache is on the C: drive. What I did to fix that is to create a symlink in C: in the composer directory, and this link targets a directory on E:, and it works like a charm, but I don't know if it'll fix your issue that is maybe more related to a package :/

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 2, 2015

No. My D: is just virtual drive. Look this :

C:\D\symfony\a>composer clear-cache
Clearing cache (cache-dir): C:\Users\Bartek\AppData\Local\Composer
Clearing cache (cache-files-dir): C:\Users\Bartek\AppData\Local\Composer\files
Clearing cache (cache-repo-dir): C:\Users\Bartek\AppData\Local\Composer\repo
Cache directory does not exist (cache-vcs-dir):

C:\D\symfony\a>composer init

Welcome to the Composer config generator

This command will guide you through creating your composer.json config.

Package name (/) [Bartek/a]: bartek/my_proj
Description []: My proj
Author: Bartek Xxxx (bartek@xxx.pl)
Invalid author string. Must be in the format: John Smith john@example.com
Author:

ghost commented Feb 2, 2015

No. My D: is just virtual drive. Look this :

C:\D\symfony\a>composer clear-cache
Clearing cache (cache-dir): C:\Users\Bartek\AppData\Local\Composer
Clearing cache (cache-files-dir): C:\Users\Bartek\AppData\Local\Composer\files
Clearing cache (cache-repo-dir): C:\Users\Bartek\AppData\Local\Composer\repo
Cache directory does not exist (cache-vcs-dir):

C:\D\symfony\a>composer init

Welcome to the Composer config generator

This command will guide you through creating your composer.json config.

Package name (/) [Bartek/a]: bartek/my_proj
Description []: My proj
Author: Bartek Xxxx (bartek@xxx.pl)
Invalid author string. Must be in the format: John Smith john@example.com
Author:

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 3, 2015

I'm just looking at :
https://github.com/composer/composer/blob/master/src/Composer/Command/InitCommand.php
and I found in line 43 regular expression
in public function parseAuthorString($author)

'/^(?P[- .,\p{L}'’]+) <(?P.+?)>$/u'

Explanation step by step from :
https://www.regex101.com/
The same explanation i deduced from :
http://www.pcre.org/current/doc/html/pcre2syntax.html#TOC1

^(?P[- .,\p{L}'’]+) <(?P.+?)>$/u
^ assert position at start of the string
(?P[- .,\p{L}'’]+) Named capturing group name
[- .,\p{L}'’]+ match a single character present in the list below
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]

  • a single character in the list - literally
    . matches the character . literally
    , the literal character ,
    \p{L} matches any kind of letter from any language
    ' matches the character ' literally
    ’ the literal character ’
    < matches the characters < literally
    (?P.+?) Named capturing group email
    .+? matches any character (except newline) [unicode]
    Quantifier: +? Between one and unlimited times, as few times as possible, expanding as needed [lazy]

matches the characters > literally
$ assert position at end of the string
u modifier: unicode: Pattern strings are treated as UTF-16. Also causes escape sequences to match unicode characters

So i think this regular expression is pretty nonsense.

I done some test in my system,

test.php

[- .,\p{L}\'’]+) <(?P.+?)>$/u','John Smith john@example.com',$match); echo "Name:$match[0]"; d:\test>php test.php Warning: preg_match(): Compilation failed: invalid UTF-8 string at offset 22 in D:\test\test.php on line 2 Name:

ghost commented Feb 3, 2015

I'm just looking at :
https://github.com/composer/composer/blob/master/src/Composer/Command/InitCommand.php
and I found in line 43 regular expression
in public function parseAuthorString($author)

'/^(?P[- .,\p{L}'’]+) <(?P.+?)>$/u'

Explanation step by step from :
https://www.regex101.com/
The same explanation i deduced from :
http://www.pcre.org/current/doc/html/pcre2syntax.html#TOC1

^(?P[- .,\p{L}'’]+) <(?P.+?)>$/u
^ assert position at start of the string
(?P[- .,\p{L}'’]+) Named capturing group name
[- .,\p{L}'’]+ match a single character present in the list below
Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]

  • a single character in the list - literally
    . matches the character . literally
    , the literal character ,
    \p{L} matches any kind of letter from any language
    ' matches the character ' literally
    ’ the literal character ’
    < matches the characters < literally
    (?P.+?) Named capturing group email
    .+? matches any character (except newline) [unicode]
    Quantifier: +? Between one and unlimited times, as few times as possible, expanding as needed [lazy]

matches the characters > literally
$ assert position at end of the string
u modifier: unicode: Pattern strings are treated as UTF-16. Also causes escape sequences to match unicode characters

So i think this regular expression is pretty nonsense.

I done some test in my system,

test.php

[- .,\p{L}\'’]+) <(?P.+?)>$/u','John Smith john@example.com',$match); echo "Name:$match[0]"; d:\test>php test.php Warning: preg_match(): Compilation failed: invalid UTF-8 string at offset 22 in D:\test\test.php on line 2 Name:
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 3, 2015

Why don't use regexp like this :

'(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)'

?

taken from http://stackoverflow.com/questions/14010875/extract-email-and-name-with-regex

Please guys ....

ghost commented Feb 3, 2015

Why don't use regexp like this :

'(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)'

?

taken from http://stackoverflow.com/questions/14010875/extract-email-and-name-with-regex

Please guys ....

@naderman

This comment has been minimized.

Show comment
Hide comment
@naderman

naderman Feb 3, 2015

Member

@croonx what does this have to do with clearing the cache? can you make a new issue please to change the regex or even submit a PR?

Member

naderman commented Feb 3, 2015

@croonx what does this have to do with clearing the cache? can you make a new issue please to change the regex or even submit a PR?

@naderman

This comment has been minimized.

Show comment
Hide comment
@naderman

naderman Feb 3, 2015

Member

Please stop debating regular expressions in this entirely unrelated resolved issue.

Member

naderman commented Feb 3, 2015

Please stop debating regular expressions in this entirely unrelated resolved issue.

@composer composer locked and limited conversation to collaborators Feb 3, 2015

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.