26 de junio de 2014

How to revive Mac App Store when its stuck forever waiting...


How to revive Mac App Store when its stuck forever waiting...

I recently went to the App Store application on my Mac to download the Lion version of Apple's Xcode development tools.  I was prompted for my Apple ID and password (which I provided) and then I left the App Store app on its own to complete the download and install.  After about 30 minutes I went to check in on its progress and saw that it had downloaded exactly 0 bytes.  The status on the Purchased page was Waiting...

Waiting for Godot

...and waiting and waiting.  I quit and restarted App Store and still my downloads were stuck waiting.  I dug around a little and it turns out this is not an uncommon problem but the remedies suggested were all over the place.  Everything from installing updates and deleting caches (both good ideas) to deleting your Library folder (not a good idea).  I like to attack problems like this by starting with the easiest and least invasive measures.

I should state right off the bat that these solutions are meant to incur as little disruption as possible but do require the use of some programs that might not be in your usual repertoire: Activity Monitor and Terminal.  If you are at all uncomfortable using these tools you can always use that old Windows chestnut... reboot.  Yes, rebooting your Mac should have the same affect as solution 1 at least.  But if you don't want the hassle of rebooting then read on.


Solution 1: Kill the Zombie

The App Store uses a process called "storeagent" that runs continuously in the background.  It seems that sometimes this process can go a little wonky and fail to respond to requests to download app purchases.  What we want to do is kill this zombie process (it will start up again automatically).

Start Activity Monitor
First, quit the App Store application (e.g. by selecting "App Store->Quit App Store" or pressing Cmd-Q or click the red dot in the top left corner of the window).  Start upActivity Monitor (you'll find it on Lion's launchpad in the Utilities collection or using Finder in Applications/Utilities/Activity Monitor.  Activity monitor is used to display the processes running on your Mac.  You could go hunt around for the process called "storeagent" but an easier method is to enter "storeagent" in the Activity Monitor filter box as illustrated below (some of the numbers will be different).  Highlight the "storeagent" process by clicking on it.  The "Quit Process" stop sign should become available.  Go ahead and click on Quit Process to kill "storeagent". You'll be asked if you really want to quit the process.  Confirm by clicking "Quit".  Normally this should do the trick and the process will disappear immediately and be replaced a little while later by a new process (with a different number in the PID column).  However, if the process is a deep zombie, you will need to click "Force Quit" in the confirmation dialog.  Do this only as a last resort as it is possible to damage system files by using Force Quit too often. 

Activity Monitor Filtered for "storeagent".  Note the "Quit Process" stop sign is now clickable.
Now go ahead and restart the App Store application.  Click on Purchased, find your purchase and select Resume. After you enter your Apple ID and password your purchase should start downloading.   However, if the App Store is still stuck in Waiting move on to Solution 2.

Solution 2 - Purge the Caches

Solution 1 has always worked for me but I've heard of cases where more intervention is required.  If this fits your situation then go ahead and quit the App Store application again.  Now we do some typing into Terminal. You can find Terminal in the same Utilities folder that you found Activity Monitor.  When you start it, it should look something like below.

At the Terminal prompt
What we're going to do is use some commands to delete App Store caches.  You do not need to worry about deleting these files since, by definition, they are a copy of what is already stored on the Apple servers and will automatically be restored.  Type of the following commands exactly as you see below (in fact, go ahead and copy and paste them into Terminal).

rm -r ~/Library/Caches/com.apple.appstore
rm -r ~/Library/Caches/com.apple.storeagent
rm ~/Library/Preferences/com.apple.appstore.plist
rm ~/Library/Preferences/com.apple.storeagent.plist
rm ~/Library/Cookies/com.apple.appstore.plist

Now go and do the steps in Solution 1 again.  Once you're done that, start up App Store, go to Purchases, and select Resume on your download.  Enter your Apple ID and password and you're off to the races.

Source: http://scheyeniam.blogspot.com.ar/2011/08/how-to-revive-mac-app-store-when-its.html?spref=bl

How to merge two folders in Mac OS X or Linux


Short answer


Using the command line (Terminal):
cp -r -n ~/Desktop/src/* ~/Desktop/destination/
The command above adds the src content and the subdirectories to the destination without overwriting the content already present in the destination.

Long answer

Even if the content overlaps, you can still use cp to do it. Assume that you have two folders on your desktop: the src and the destination folders and you want to merge src into destination:
enter image description here
To merge, just do:
cp -r ~/Desktop/src/* ~/Desktop/destination/
NOTE When you use this, the content in src overwrites the content in the destination folder and adds the extra stuff that are missing in the destination. It shouldn't matter if you just want to add the missing files from src into destination.
ALSO it doesn't matter how many subdirectories are there, it will just go through each folder recursively and it will overwrite the content and will add the stuff that is missing in the destination folder.
BUT
PITFALL If you have huge files (like video files), you don't want to wait until everything is overwritten, it adds a lot of overhead.
PITFALL SOLUTION: Instead, you can use the -n flag to skip the overwriting:
cp -r -n ~/Desktop/src/* ~/Desktop/destination/
This is the description of the -n flag from the man page:
man cp
 -n    Do not overwrite an existing file.  (The -n option overrides any
       previous -f or -i options.)
Further Reading
  1. http://stackoverflow.com/questions/5088332/overhead-of-a-flag-in-cp-command
Source: