Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FSI.exe does not work under Ubuntu 10.10

Update: Tried November CTP release. Same error message. Forgot to mention that this server has the Ubuntu server edition installed. I don't have this issue on my Ubuntu desktop that runs Desktop 10.10. So I suspected that it could be some command line related libraries missing. After I installed libreadline-dev and libreadline5, the error message disappeared. However, the issue that fsi stuck is still there.

Update2: Tried the new Mono 2.8.1. Same FSI stuck issue.

Update3: As this issue is very reproducible, I reported it as a bug in fsi.exe to Microsoft. Let's see how it goes.

Update4: Got quick response from Don Syme. The solution he suggested resolved this issue. I created the answer myself.

Hi,

I installed F# 2.0 in a server running Ubuntu 10.10 and Mono 2.8. fsc.exe runs perfect, I have no problem in compiling fs files. However, when I run fsi.exe as follows: mono /usr/local/FSharp/bin/fsi.exe

I got the FSI prompt, but an error message keep repeating

"Failed to install ctrl-c handler - Ctrl-C handling will not be available. Error was: Exception has been thrown by the target of an invocation"

Am I missing anything here?

The Mono 2.8 was compiled and installed from source.

like image 925
Cygwin98 Avatar asked Nov 23 '10 14:11

Cygwin98


2 Answers

Feel really awkward to answer my own question. Anyway, I'll answer it so other people can benefit from.

First of all, install libreadline-dev and libreadline5 so you can get rid of the following error message

Failed to install ctrl-c handler - Ctrl-C handling will not be available. Error was: Exception has been thrown by the target of an invocation

If you encounter fsi.exe stuck issue, try

 fsi --gui-

It works perfectly in my case.

Here is my understanding of why such an issue happened. If you look into the code, you will find out fsi.exe actually references System.Windows.Forms, which further links to the Window system. In my case, I ran fsi in a server without X system installed. Consequently, fsi stuck there trying to talk to the nonexistent X. That explains why I don't have the issue in my desktop.

like image 189
Cygwin98 Avatar answered Oct 18 '22 16:10

Cygwin98


F# has never worked for me under Linux. Today with Mono 2.8 and the November 2010 drop of F# (which confusingly has the exact same version number as the previous release?!) I get:

$ sudo ./install-mono.sh
In order to add FSharp.Core.dll to the Mono GAC the DLL needs to be
re-signed with the mono.snk key. The mono.snk key is available from
the 'Mono Sources'.

  http://www.mono-project.com/
  http://github.com/mono/mono/raw/master/mcs/class/mono.snk

For example, run:
  wget -O mono.snk http://github.com/mono/mono/raw/master/mcs/class/mono.snk

Then re-run this script.

An alternative to installing the DLLs in the Mono GAC is to add the
FSharp bin directory to the MONO_PATH variable. For more information
on 'How Mono Finds Assemblies' see http://www.mono-project.com/Gacutil

If I run the wget command that it suggests then it dies:

$ wget -O mono.snk http://github.com/mono/mono/raw/master/mcs/class/mono.snk
--2010-11-23 17:02:43--  http://github.com/mono/mono/raw/master/mcs/class/mono.snk
Resolving github.com... 207.97.227.239
Connecting to github.com|207.97.227.239|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://github.com/mono/mono/raw/master/mcs/class/mono.snk [following]
--2010-11-23 17:02:44--  https://github.com/mono/mono/raw/master/mcs/class/mono.snk
Connecting to github.com|207.97.227.239|:443... connected.
ERROR: certificate common name `*.github.com' doesn't match requested host name `github.com'.
To connect to github.com insecurely, use `--no-check-certificate'.
Unable to establish SSL connection.

Now if I rerun the F# installer I get a different error:

$ sudo ./install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
ERROR: Invalid number of parameters.

Usage: sn [-q | -quiet] options [parameters]

 -q | -quiet            Quiet mode (minimal display)

Help options
 -? | -h                Show this help screen about the tool
 -? | -h config         Configuration options
 -? | -h csp            Crypto Service Provider (CSP) related options
 -? | -h convert        Format convertion options
 -? | -h sn             StrongName signing options
-- Installing FSharp DLLS into the GAC
Failure adding assembly bin/FSharp.Core.dll to the cache: Strong name cannot be verified for delay-signed assembly

If I copy the mono.snk file from the Mono 2.8 directory into the F# directory by hand then the installer seems to work:

$ sudo ./install-mono.sh
-- Resigning FSharp.Core.dll with mono.snk
Assembly bin/FSharp.Core.dll signed.
-- Installing FSharp DLLS into the GAC
Installed bin/FSharp.Core.dll into the gac (/usr/local/lib/mono/gac)

But F# itself still fails to work in exactly the same way that it did before (appearing to hang whenever input is entered):

$ mono bin/fsi.exe

Microsoft (R) F# 2.0 Interactive build 2.0.0.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> 1+2*3;;

I have to use CTRL+Z to regain control and then kill %1 to kill the rogue process.

like image 1
J D Avatar answered Oct 18 '22 15:10

J D