3

I am desperately trying to install Hubris but the installation fails whenever I run "cabal install".

Link to Hurbis:
https://github.com/mwotton/Hubris/tree/master/Haskell

Link to the Cabal file:
https://github.com/mwotton/Hubris/blob/master/Haskell/hubris.cabal

The cabal command that fails is:

cabal install --extra-include-dirs=/usr/include/ruby-1.9.1/x86_64-linux --extra-include-dirs=/usr/include/ruby-1.9.1 --extra-lib-dirs=/usr/lib --user  --enable-shared  --with-ghc=/usr/local/bin/ghc

The error message is:

Resolving dependencies...
Configuring hubris-0.0.4...
cabal: Missing dependencies on foreign libraries:
* Missing C libraries: ruby, ruby, ruby
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
cabal: Error: some packages failed to install:
hubris-0.0.4 failed during the configure step. The exception was:
ExitFailure 1

THE RAKE ERROR IS THE SAME:

+install -c tmp/x86_64-linux/stub/1.9.3/stub.so lib/stub.so
cabal: Missing dependencies on foreign libraries:
* Missing C libraries: ruby, ruby, ruby
This problem can usually be solved by installing the system packages that
provide these libraries (you may need the "-dev" versions). If the libraries
are already installed but in a non-standard location then you can use the
flags --extra-include-dirs= and --extra-lib-dirs= to specify where they are.
cabal: Error: some packages failed to install:
hubris-0.0.4 failed during the configure step. The exception was:
ExitFailure 1
rake aborted!
ERROR: ran cabal update; cd Haskell; cabal install --extra-include-    
dirs=/usr/include/ruby-1.9.1/x86_64-linux --extra-include-dirs=/usr/include/ruby-1.9.1 -
-extra-lib-dirs=/usr/lib --user  --enable-shared  --with-ghc=/usr/local/bin/ghc, got 
Downloading the latest package list from hackage.haskell.org

I also installed 'ruby-dev', e.g.

apt-get install ruby1.9.1-dev

Probably the error is related to missing header files and wrong include directories when I run the cabal command.

.

System Configuration:

 ubuntu 12.04
 GHC version 7.4.1
 ruby version 1.9.3p0
 gem version 1.8.24
mrsteve
  • 4,082
  • 1
  • 26
  • 63

2 Answers2

2

You should install Hubris using rake. Simply invoking rake in the root of the repository should work. The task that builds the library will find the relevant ruby include directories for you.

I had to make some changes to make the compile work with modern Haskell (E.g. Haskell Platform 2012.2.0.0). The changes are available at https://github.com/dflemstr/Hubris.

It works for me on Arch Linux:

Arch ... well it's rolling release, so there is no version number
GHC version 7.4.2
ruby version 1.9.3p194 (2012-04-20 revision 35410)
gem version 1.8.23
dflemstr
  • 25,947
  • 5
  • 70
  • 105
  • thank you for you answer. Of course I ran the rake command first, but this fails with the exact cabal command as printed above. – mrsteve Jul 15 '12 at 16:35
  • It works perfectly for me, although I'm running Arch Linux on the computer that the compile is happening on. I will try to reproduce on Ubuntu in a sec. – dflemstr Jul 15 '12 at 16:43
  • that would be really great! also the info that it works on arch linux is very helpful. – mrsteve Jul 15 '12 at 16:47
  • Note that I had to make *some* changes to the actual Haskell code, because it is over three years old, written for some Haskell98/2010 hybrid, and pretty poorly written to begin with, but the actual cabal part worked perfectly. – dflemstr Jul 15 '12 at 16:55
  • It would be very nice to have your changes of the haskell code (if you post them or perhaps if you fork the github repository). Also it would help if you could write the version numbers of ruby, ghc, gem, rake. I will edit the answer and I will write a directory listing of the included dirs of the cabal command, e.g. of '/usr/include/ruby-1.9.1' – mrsteve Jul 15 '12 at 17:20
  • I can't get it to work with Ubuntu, probably because of the Ubuntu convention of suffixing libraries with their version numbers (e.g. `libruby1.8.so.1.8`), but I'll post the Arch Linux details. – dflemstr Jul 15 '12 at 17:29
  • I think your last comment is right on the spot (but I have to still test it). In Ubuntu I created a symlink: 'sudo ln -s /usr/lib/libruby-1.9.1.so /usr/lib/libruby.so' and now I get a different error. The new error is : 'Language/Ruby/Hubris/LibraryBuilder.hs:13:8: Could not find module Control.Monad.Error.Class' Perhaps you haven't installed the "dyn" libraries for package mtl-2.1.1'?' – mrsteve Jul 15 '12 at 18:41
  • @MarkWotton, the changes made are below my standards for a pull request, but if you insist... – dflemstr Jul 15 '12 at 23:05
  • dflemstr: re bad code: yeah, there are some rough edges to it, and I haven't really hacked on it in earnest for some time. it's not entirely clear what the right model for bundling dylibs is - possibly a better approach would forgo the ability to play with code at the prompt, and just let you build explicit packages. It'd certainly help with deployment. – Mark Wotton Jul 15 '12 at 23:09
1

FINAL ANSWER!!! EVERYTHING WORKS!!!

The credit for the right answer goes to User 'dflemstr'. BUT look at this answer for some details, especially for Ubuntu Users. Credit also goes to Mark Wotton, as the install errors where mainly due to Haskell/Cabal and Ubuntu.

_
Requirements:
(tested with this setup, other version probably work too)

  1. Ubuntu 12.04 (Arch Linux works too)
  2. Ruby 1.9.3p0
  3. GHC 7.4.1
  4. Haskell Platform 2012.2.0.0

_
Ruby Installation

sudo apt-get install libruby1.9.1 libruby1.9.1-dbg libtcltk-ruby1.9.1 ruby1.9.1 ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full rubybook rubygems  

_
Gem Update System (optional)

sudo env REALLY_GEM_UPDATE_SYSTEM=1 gem update --system

_
Fix for Ubuntu
(error Missing C libraries: ruby, ruby, ruby)

 cd /usr/lib
 ln -s libruby-1.9.1.so ./libruby.so

_
GHC Installation
NOTE: I don't use any ubuntu packages for GHC and the haskell platform. Some people on stackoverflow recommend this.

http://www.haskell.org/ghc/download_ghc_7_4_1 (follow the instructions on the website)

_
Haskel Platform Installation
http://lambda.haskell.org/platform/download/2012.2.0.0/haskell-platform-2012.2.0.0.tar.gz
(again follow the instructions on the website)
.

_
Enable shared library support for haskell packages

Add the following line: "shared: True"

nano ~/.cabal/config

_
Reinstall every haskell package with shared support
Follow the instructions given in:

  1. Building a haskell interpreter (hint) as dynamic library, useable from C++: Missing Interpreter.dyn_hi
  2. Cabal rebuild all with enable-shared flag

NOTE: The above instructions did not work for me!! In that case, manually reinstall every package by hand (!) with force:

cabal install hint-0.3.3.4 --reinstall --force-reinstall

Repeat with every installed package! e.g. also the mtl package, etc. You may get the same error with a package that is needed for the reinstallation. Just reinstall that package and any recursive dependencies.

If you install Hubris right away, i.e. skipping this step, you get the following error (only in ubuntu, not arch linux):

Language/Ruby/Hubris/LibraryBuilder.hs:13:8:
Could not find module `Control.Monad.Error.Class'
Perhaps you haven't installed the "dyn" libraries for package `mtl-2.0.1.0'?
Use -v to see a list of the files searched for.
cabal: Error: some packages failed to install:

Install needed haskell packages

cabal install c2hs

Install needed ruby packages

sudo gem install rake open4 rspec hoe
sudo gem install bundler
sudo gem install rake-compiler
sudo gem install rspec

Get Hurbis via github

git clone https://github.com/dflemstr/Hubris.git

(Note: This is just for now. As the changes are merged, the original github version from Mark Wotton should be pulled!)

Fix Rakefile to find GHC in ubuntu

Change "/usr/bin/ghc" to "/usr/local/bin/ghc":

cd Hubris
nano Rakefile

Run rake

cd Hubris
rake

If you get errors like "Perhaps you haven't installed the 'dyn' libraries for" here it is possibly due that some package are not reinstalled (see step: 'Reinstall every haskell package with shared support').

**Install Hubris*

cd Hubris
sudo rake install

Install rake

Fix permissions:

chmod -R 777 /var/hubris

NOTE: Don't use 777!! If you do, change later to 755 or 766, etc. This is just for testing!

This is needed because rake install is done with 'sudo' but the cabal packages are installed with a different user. Hubris compiles the haskell files in /var/hubris/ which is not accessible for a regular user unless you change the permissions.

Run test example Add the following lines to "test.rb":

require 'hubris' # best line ever

class Target
  hubris :inline =>"triple::Int->Int; triple n = 10*n"
end

t = Target.new
puts t.triple(3)

Execute test.rb:

ruby test.rb

Check if the result is okay:

The last three lines of the console output should be:

... many lines and possibly GHC error messages ...
|
error ||
30

If the last line is "30" then everything works!! Note that when you run the command a second time the inline haskell is not recompiled, therefore the output is much shorter, but the last line is still "30".

Final Words Thanks to Mark Wotton for providing Hubris!! It is an excellent starting point to add new features to the library. Great that it is open source!

Community
  • 1
  • 1
mrsteve
  • 4,082
  • 1
  • 26
  • 63