Category Archives: Computers

Mac OS X and Windows

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

How to force Remote Desktop Connection to 256 colours

Windows Remote desktop is great. It’s less great if you connect to a computer over a slow internet connection and want to do some actual work. It’s even less great when you’ve finally migrated to Windows 7 and found that you no longer have a 256 colors option, but instead have to use 15-bit color at least, which becomes achingly slow.

Help is at hand. Simply save your connection settings. This create a .rdp file which is a text file you can edit. Not far from the top you’ll see the bits-per-pixel setting:

screen mode id:i:2
use multimon:i:0
desktopwidth:i:1920
desktopheight:i:1080
session bpp:i:15
...etc...

Change the 15 to an 8. Save it, and open the file in Remote Desktop. Although the GUI still shows ‘Thousand of Colors’ in the dropdown, when you connect you’ll find it’s actually 256 colors. Much, much faster.

Thanks to Raymond Diack, http://social.technet.microsoft.com/Profile/raymond%20diack/activity.

VS2010 Command Prompt Here on the Windows Explorer Right Click Menu — the .reg File

VS2010 Command Line Here for Explorer Right Click Menu

To add a Visual Studio 2010 Command Prompt Here to your Explorer Right-Click menu, save this as a .reg file to your desktop, and then run it:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Line VS2010]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Line VS2010\command]
@="cmd.exe /k echo on & pushd \"%1\" & \"C:\\Program Files\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" x86"

If you have 64-bit Windows, you’ll need this:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Line VS2010]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Line VS2010\command]
@="cmd.exe /k echo on & pushd \"%1\" & \"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\vcvarsall.bat\" x86"

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