Using F# On Mac and Linux (with Mono)

For Mac OS/X users, install Mono

For Debian users, use your package manager to get

  • mono-runtime
  • mono-gac
  • mono-tools
  • libmono-winforms2.0-cil
  • libmono-system-runtime2.0-cil

You must get the last two packages! Get the packages like this

sudo apt-get install <package names>

or use Synaptic Package Manager

Please ensure that the Mono version you are getting is at least Mono 2.6. Ubuntu Lucid currently has only Mono 2.4 you can get Mono 2.6 from Badger Ports - (http://badgerports.org/)

Getting and Installing F#

Download the latest version of F#"

Unzip the distribution file. Then

cd FSharp-1.9.9.9 (or other)

chmod u+x install-mono.sh

sudo ./install-mono.sh

Now follow the instructions "custom writing":http://customwritingservices.org/ to get a copy of mono.snk. Then rerun install-mono.sh

sudo ./install-mono.sh

Look carefully for failures etc.

Using F# Interactive (fsi.exe)

Start the F# Interactive command line compiler:

bin/fsi.exe

Type your first F# program:

printfn "hello world"

You're off!

Using the F# Compiler (fsc.exe)

Run the F# Interactive command line compiler:

bin/fsc.exe --resident

The --resident flag makes the compiler faster on subsequent invocations.

FAQ

What should I use to edit my code?

If you are only running code on Mono/Linux/Mac, and developing on Windows, then you should use the Visual Studio 2008 Shell plus F#, or use Visual Studio 2010. Mount your Mac/Linux directory.

If developing on Mac/Linux, there are many choices. At the time of writing the following editors have specific support for F#, either builtin or through addons provided by the F# community:

  • TextMate
  • Emacs
  • VIM

Other choices are GEdit.

Why is mono.snk required?

This is required because FSharp.Core.dll is strong-named with a .NET release key. Mono treats these DLLs using special rules, and the DLL must be strong-named with the Mono key. This doesn't affect the logical identity of the DLL. The install-mono.sh script tells you where to get a copy of mono.snk.

Why does the F# compiler (fsc.exe) take a while to compile an empty file?

This is because the compiler is not pre-compiled. Use the --resident flag, and your subsequent compiler invocations will be faster.

Why does the F# interactive (fsi.exe) take a while to respond to first input?

This is for the same reason.

Why do I get a "Missing System.Runtime.Remoting.dll" error?

You must install these mono packages:

  • libmono-winforms2.0-cil
  • libmono-system-runtime2.0-cil

If you don't, you will get a "missing System.Runtime.Remoting.dll" exception, among others.

I always get "warning FS0000: Could not determine highest installed .NET framework version from Registry keys, using version 2.0"

This was a known problem with F# 1.9.7.8. Upgrade to F# 1.9.9.9.