Category Archives: Uncategorized

Running Fiddler on Mac OS X

Fiddler is an awesome HTTP debugging proxy server application that can really come in handy for software development.  If you haven’t used it before, you should definitely check it out.  While I’ve normally been running a Windows machine I recently decided to try out using a MacBook Pro, and it wasn’t long before I needed Fiddler.  They have a beta build out that utilizes the Mono framework, but I had a little trouble getting it to run on my Mac.

If you’re installing Mono for the first time, you’ll need to run this command at a command prompt:

/Library/Frameworks/Mono.framework/Versions/current/bin/mozroots --import -- sync

This assumes you have a symlink for your latest version of Mono at /Library/Frameworks/Mono.framework/Versions/current; if not, or if you have Mono installed to a different path, just replace the path to your installation’s bin directory accordingly. The install instructions included with Fiddler for OS X has more on this. For Fiddler, you simply need to extract it to a folder you have write access to. I chose ~/Applications/fiddler-mac. Assuming the Mono bin directory is added to your PATH environment variable, you then just have to run mono Fiddler.exe in Terminal (from the directory you extracted Fiddler to).

Since 64-bit Mono is not fully supported at the time of this posting, you have to force it to run as 32-bit.  Of course, being an avid PowerShell user I’m also running PowerShell on my Mac.  It has its quirks when running on a system other than Windows, but more on that later.  Anyway, although it’s trivial to launch Fiddler when needed I prefer things easy and added this little gem to my PowerShell profile to easily launch it from the command-line:

# again, this assumes your Mono framework is installed at the specified path
# it also assumes you have Fiddler extracted to '~/Applications/fiddler-mac/'
if(-not (Get-Command mono -ea SilentlyContinue)) {
  $env:PATH = $env:PATH.TrimEnd(':') + ':/Library/Frameworks/Mono.framework/Versions/current/bin';
}
function Start-Fiddler {
[CmdletBinding()]
param (
  [Parameter(Position=0, Mandatory=$false)]
  [ValidateNotNullOrEmpty()]
  [string] $fiddlerPath = '~/Applications/fiddler-mac/fiddler.exe'
)

  mono --arch=32 $fiddlerPath
}
Set-Alias fiddler Start-Fiddler -Scope Global

And of course, now all I have to do is type fiddler from my PowerShell prompt to run Fiddler.

Running PowerShell on Mac OS X

As I mentioned in a previous post, I’ve been [trying] to use a Mac for development here at OneCause. Of course, that’s “impossible” without PowerShell…but I ran into a couple of issues right off the bat when trying to use it.

I tend to run with a customized prompt, so the first issue I ran into involves making sure you return something (anything–in my case, I’m just returning a single space).  If you don’t, PowerShell assumes the <code>prompt</code> function failed to do its job and uses its own function anyway.

One of the PowerShell modules I use most is posh-git; although there are many things I’d like to improve about it, it continues to grow and I can’t imagine living without it.  When first using PowerShell on Mac OS X, it looked like the <code>prompt</code> function was being called multiple times and when I’d start typing anything the cursor would needlessly jump around.  I have a custom prompt.  Originally I thought it was related to a PSReadLine issue, before moving on to troubleshooting by removing various lines one at a time.  Ultimately it was the PSReadLine issue, which I was unable to resolve in PowerShell itself–any attempts to update or install that module were useless, sometimes resulting in multiple copies of the module being installed.  I was able to clear the directory PSReadLine was in (found using <code>(Get-Module PSReadLine).Path</code> and replacing the contents with that of a Beta1 release of PSReadLine 2.0 I downloaded.  And now my console prompt is back to normal: