CSVProvider in fsharpi on linux

I’m typing this in fsharpi on linux (ubuntu 18.04, latest packages available installed as explained on fsharp.org):

open FSharp.Data
let csvstring = @"Column1;Column2;Column3
type CsvRecords = CsvProvider< csvstring, Separators=";", HasHeaders=true >

but I get this error:

 error FS0039: The type 'CsvProvider' is not defined. Maybe you want one of the following:

The only completion proposed is for FSharp.Data.UnitSystems.

What am I doing wrong?


Did you reference the FSharp.Data.dll using #r? Otherwise, fsharpi won’t know that CsvProvider exists. For example:

// loads the FSharp.Data.dll from nuget cache
#r ~/.nuget/packages/fsharp.data/2.4.6/lib/net45/FSharp.Data.dll;;

Thanks for your help. However I don’t find that dll:

:~$ dpkg -l | grep fsharp
ii  fsharp                                       4.1.33-0xamarin7+ubuntu1804b1                               all          functional-first programming language - compiler for the CLI
ii  libfsharp-core4.3-cil                        4.1.33-0xamarin7+ubuntu1804b1                               all          functional-first programming language - core runtime library

:~$ dpkg -L fsharp | grep "\.dll"

:~$ dpkg -L libfsharp-core4.3-cil | grep "\.dll"

I followed the install instructions here. Is it supposed to be available out of the box? Do I need to get it with nuget first? How?

Right. The FSharp.Data library isn’t actually a core library. It separate package that needs to be downloaded (via paket or the nuget client). Here’s the nuget repo url: https://www.nuget.org/packages/FSharp.Data/3.0.0-beta4.

You can run the following command to get the library:

dotnet add package FSharp.Data --version 3.0.0-beta4 

The FSharp.Data.dll should then be available here ~/.nuget/packages/fsharp.data/3.0.0-beta4/lib/net45/FSharp.Data.dll. This ~/.nuget folder is where the dotnet cli caches all of these nuget packages.

1 Like

Thanks for the clarification. Is there a way to install it without creating a project? It says

Could not find any project in `/home/user/`.
Usage: dotnet add <PROJECT> package [options] <PACKAGE_NAME>

I’d like to first test it in the REPL, without creating a project. Is that possible?

You can just go to nuget.org to download the package and place some where then you can by using #r “the package dll you downloaded”. But by this you have to download other packages manually if it needs. You can also use paket manage this automatically for you without to create a project. https://fsprojects.github.io/Paket/getting-started.html. Or use fake (http://fake.build/fake-gettingstarted.html) to do this for you.


Thanks! I’ll experiment with those.