Tag Archives: OS X

Mac OS X

MacBook Pro doesn’t go to sleep properly / Spotlight takes ages at start up – NTFS

I’ve had this problem on and off for years, with 2 MacBooks, that they took as much as a minute to fall asleep or failed to do so at all. At the moment my current theory is that Tuxera NTFS / NTFS-3G have been the culprits: it would sometimes use 30% CPU to do nothing and killing it let the machine sleep. And I think it’s responsible for the problem I have that SpotLight doesn’t work properly for several minutes after first starting up the machine and logging in – it seems to be indexing the BootCamp partition.
I’ve recently install the current version, 2012.3.4 and it was fine for a while – sleep and spotlight problem resolved. But they still came back and at the moment I’m working with NTFS not mounting the BootCamp partition.

Which is fine until I want to copy something onto it for use in Windows… Grrr. So at the moment my workaround is to use the Tuxera System Preferences Pane to manually switch it on and off when needed.

There are other solutions for NTFS support in OS X, but the Apple unreleased one isn’t recommended which leaves you with the paid ones, Tuxera or Paragon, or the free Tuxera one, NTFS-3G.

Permission denied errors with HomeBrew & Maven / Could not resolve dependencies with lein

Like so many developers with a Mac I was pleased with the fact that homebrew at last offered package management on OS X that works as easily as it does on linuxes; but never quite managed to deal with all the issues that brew doctor listed.

Which I could ignore until I started using maven and leiningen (which uses maven). Because maven is itself a package manager, so the user id with which you brew installed it may prevent you using it later.

It starts (in my case) with

brew install maven

which failed because I didn’t have write access to /usr/local/opt or something.
Undoubtedly the right step in future is to chmod /usr/local/ at this point. But I didn’t, instead I

sudo brew install maven

which worked. This might not have mattered but then I also

sudo brew install leiningen

Which installed something or other into my maven repository. As root. I tested my new install with lein new at the command line and that works so I merrily plough ahead with installing clojure and leiningen plugins into my IntelliJ IDE, try the get started project and … get errors in the ide:
ExceptionInfo: Could not resolve dependencies: Could not resolve dependencies
Back to the command line, and I realise that although lein new works, almost no other lein command does – they all fail with a million lines of output somewhere in which I find some permissions issue when trying to install a different version of clojure to the one I’d already installed:

Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.pom from repository central at http://repo1.maven.org/maven2
[WARNING] Unable to get resource 'org.clojure:clojure:pom:1.3.0' from repository central (http://repo1.maven.org/maven2): Specified destination directory cannot be created: /Users/myusername/.m2/repository/org/clojure/clojure/1.3.0
Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.pom from repository clojars at http://clojars.org/repo/
[WARNING] Unable to get resource 'org.clojure:clojure:pom:1.3.0' from repository clojars (http://clojars.org/repo/): Specified destination directory cannot be created: /Users/myusername/.m2/repository/org/clojure/clojure/1.3.0
Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.jar from repository central at http://repo1.maven.org/maven2
[WARNING] Unable to get resource 'org.clojure:clojure:jar:1.3.0' from repository central (http://repo1.maven.org/maven2): Specified destination directory cannot be created: /Users/myusername/.m2/repository/org/clojure/clojure/1.3.0
Downloading: org/clojure/clojure/1.3.0/clojure-1.3.0.jar from repository clojars at http://clojars.org/repo/
[WARNING] Unable to get resource 'org.clojure:clojure:jar:1.3.0' from repository clojars (http://clojars.org/repo/): Specified destination directory cannot be created: /Users/myusername/.m2/repository/org/clojure/clojure/1.3.0
An error has occurred while processing the Maven artifact tasks.
 Diagnosis:
Unable to resolve artifact: Missing:
----------
1) org.clojure:clojure:jar:1.3.0

  Try downloading the file manually from the project website.
..etc ... etc..

Grr. I suppose I’d better try to fix those brew doctor errors.

Fixing the homebrew brew doctor errors

I decide to ignore the errors the brew doctor gives about other *-config files installed. Why shouldn’t I have? I also ignore homebrew’s desire to have /usr/local/bin ahead of /usr/bin in my path as I have no idea what the impact of changing it will be. I assume Apple set it that way but then again maybe macPorts did it a decade ago.

But I do want to fix the ‘no write permissions issues’:

This set of errors:
Warning: /usr/local/etc isn't writable.
You should probably `chown` /usr/local/etc
...
Warning: /usr/local/include isn't writable.
You should probably `chown` /usr/local/include
...
Warning: /usr/local/share isn't writable.
You should probably `chown` /usr/local/share

I fixed this not by chowning but by adding myself to the wheel group, which might or might not have been a bad idea. But I didn’t like the idea that the homebrew install on my machine was tied to my login.

# "g+u" copies all the permissions that the user has to the group
sudo chmod -R g+u /usr/local/share/
# add myself to the wheel group so that I have group access to all the stuff that homebrew installed
# actually I could have sworn I already was a member of wheel because of being an admin user but I didn't see wheel when I typed id. 
sudo /usr/sbin/dseditgroup -o edit -a myusername -t user wheel

Fixing the maven repository ‘Specified destination directory cannot be created’ errors

This isn’t too hard. I examine the exact path in the error message and then find that my earlier sudo brew install leiningen has resulted in the org.clojure directory in my maven repository being owned by root, and I have no write permissions to it:

ls -l /user/myusername/.m2/repository/org
# rwxr-xr-x   6 myusername  staff  204 Jan  9 14:59 antlr
# drwxr-xr-x  10 myusername  staff  340 Jan 14 15:37 apache
# drwxr-xr-x   4 myusername  staff  136 Jan  9 14:58 aspectj
# drwxr-xr-x   9 myusername  staff  306 Jan  9 14:59 atmosphere
# drwxr-xr-x   3 root      staff  102 Jan 15 06:59 clojure
# aha. Bits of my repository - the clojure dir -  is owned by root and I don't have write permissions.
#
# This time I'm happy to chown because the repository is in my home directory anyway.
sudo chown -R myusername /Users/myusername/.m2/repository/

If was starting from scratch I’d probably prefer a repository for the machine, but I didn’t pay attention to the
=> Caveats
Standalone jar and dependencies installed to:
$HOME/.m2/repository

message when I installed maven. Because of course I just wanted to install maven and get on with using it.

And now leiningen works. Mostly.

Now I try lein again:

lein test

Woohoo. lein can now successfully downloads its dependencies, and it works.
Back to IntelliJ and press the lein go button: that works too. Now I can run and test clojure.
But wait. Now I try to follow the palletOps quickstart instructions and I get error messages again. Eventually I find that there are files in ~/.lean which are also owned by root so I also need:

sudo chown -R myusername /Users/myusername/.lein

Remove HomeBrewed leiningen and download leiningen 2 from Github

By this time I was fed-up. And, homebrew had installed lein 1.7.1 but lein 2 is already mainstream. So I gave up on the homebrew‘d install of leiningen and went native as per https://github.com/technomancy/leiningen/wiki/Upgrading. (Give or take the fact that I’ve got curl on OS X, not wget. Oh wait, there’s a brew for that 😉 )

sudo brew uninstall lein
sudo rm -Rf ~/.lein
sudo curl https://raw.github.com/technomancy/leiningen/preview/bin/lein -o /usr/bin/local/lein
lein self-install

There. That’s better. Now it works properly.

References

Opening a BootCamp Drivers download or other pkg or dmg file on Windows 7 or 8 with 7-Zip

If you’ve downloaded bootcamp drivers for Macs to run Windows 7 or 8, but have done the download in Windows, you may be stuck on how to open the downloaded BootCampESD.pkg file you’ve now got.

The answer is to get a copy of 7-zip, which is free, and which is your ‘Swiss army knife’ to open the Apple .pkg and .dmg files and the ISO file inside.

  1. Launch 7-zip
  2. In 7-zip, open the BootCampESD.pkg. Inside you’ll find a Payload file and a few other files. Double click the Payload file.
  3. Inside is a folder, which you double click. Inside that another folder, which you double click. Inside that … just keep clicking down the levels of nested folders.
  4. Eventually, several levels down, you’ll get to a file called 0.Apple_ISO or some such.
  5. Now, extract this o.Apple_ISO to the desktop (or somewhere) and rename it to Apple.ISO.
  6. Now, either: Mount it by double clicking it—should work in Windows 7—or else by getting hold of PowerISO or similar; OR use 7-zip again to open this ISO file, and extract the contents to a folder.
  7. These are you driver installers. Create an empty folder on your desktop, and drag them out into it.
  8. Finally, open the folder you just created, and run the setup.exe

BootCamp Drivers – Direct Download of BootCampESD.pkg for Macs to Run Windows 7 or Windows 8

Do you find that BootCamp assistant download is stuck or or fails or could not continue?

The brute force solution: it’s a darned large download, so physically take your machine to somewhere with a very fast internet connection that can download 600MB – 1GB in a couple of minutes. There, you’re done.

For the rest of us, there are 2 options:

The simple solution – recommended – is to use this list of Windows driver download links for Macs with OS X Mountain Lion (which includes all retina display macs) or Lion, Snow Leopard or Leopard. That’s about everything back to 2007.
There are also older links here, but they appear to be redundant — the Mountain Lion file covers Mac models going back to Leopard.

Finally, the DIY solution: Work out for yourself which download link you need.

The DIY way to find your BootCampESD.pkg download link from the sucatalog

Not for the faint-hearted.

  • Apple software update uses an sucatalog file, which contains a link to a BootCampESD.pkg file which contains the drivers. The sucatalog file in question contains several different links to bootcampesd.pkg, fordifferent Mac models. How to find the right one for your machine?
  • Tim Valenta did instructions in Nov 2011 that nearly worked for me in June 2012 at http://blog.timvalenta.com/2011/11/19/boot-camp-driver-downloads/ except that again, 6 months on, the catalog file seems to be laid out everso slightly differently; and the file downloaded is now in an easier to use format.
  • My steps to download the Lion or Mountain Lion drivers were as follows:

    How to Manually Download Windows Drivers for Macs Running BootCamp 4 or BootCamp 5

    1. Download from apple the http://swscan.apple.com/content/catalogs/others/index-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog file. Don’t double-click it, that won’t help.
    2. Instead, open it in a text editor or word processor.
    3. Search for each occurrence — as at August 2012 there were 6 — of BootCampESD.pkg. For instance, the one I needed is http://swcdn.apple.com/content/downloads/33/54/041-2011/pRtCDYcWShMLxFggy3TzFzmfnnWQNFQBfJ/BootCampESD.pkg
    4. Notice in each such URL, the /041-2011/ or similar /041-XXXXX/ bit of it.
    5. Below each such occurrence, notice a URL for a file with the same 041-XXXXX in it and ending in English.dist, e.g. 041-2011.English.dist
    6. Paste the URL for each such English.dist file into your browser and open the Url. Here’s a list of them:
    7. Search for the Model Identifier for your Mac. For instance MacBookPro5,2 or Macmini4,1 or whatever
      • For instance the 041-2011 file contains these models: MacBook2,1 MacBook3,1 MacBook4,1 MacBook5,1 MacBook5,2 MacBook5,3 MacBook6,1 MacBook7,1 MacBookAir1,1 MacBookAir2,1 MacBookAir3,1 MacBookAir3,2 MacBookPro2,1 MacBookPro2,2 MacBookPro3,1 MacBookPro4,1 MacBookPro5,1 MacBookPro5,2 MacBookPro5,3 MacBookPro5,4 MacBookPro5,5 MacBookPro6,1 MacBookPro6,2 MacBookPro7,1 MacBookPro8,1 MacBookPro8,2 MacBookPro8,3 MacPro1,1 MacPro2,1 MacPro3,1 MacPro4,1 MacPro5,1 Macmini2,1 Macmini3,1 Macmini4,1 iMac5,1 iMac6,1 iMac7,1 iMac8,1 iMac9,1 iMac10,1 iMac11,1 iMac11,2 iMac11,3 iMac12,1 iMac12,2
      • How do you know your Model Identifier? Open System Information, and look in the Hardware Overview section. i.e. click Apple menu -> About this Mac -> More Info… -> Report -> Hardware -> and now read down the Hardware Overview looking for “Model Identifier:”
    8. Having found your 041-XXXXX number, download the BootCampESD.pkg url that has your number in it. I try to keep the page at bootcamp-driver-download up to date with all the pkg download URLs.
    9. Be patient as it’s probably 600MB.
    10. Once your pkg is downloaded, double click it and install to a folder on your hard drive so you know where to find it.
    11. The folder contains a nest of folders, the last of which contains a dmg disk image file. Double click to open. Voila. Here are your Windows installer files. Again, the page at bootcamp-driver-download has pictures to help.
    12. Copy them to a thumb drive or a burnable CD or something. The point here is that you need the somewhere that a new install of windows with only minimal drivers can read them. NB, it’s still 660MB or more, so it’s a full CDs worth of burning time.
    13. You can now proceed with Boot Camp assistant Windows installation, which will eventually reboot your machine for startup in Windows.
    14. Once you’re in Windows, run the installer that you saved to CD or thumb drive.
    15. Done. Marvel as all your Apple hardware now works nearly as well as it does in Mac OS X.