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
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
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)
Ubuntu 12.04 (Arch Linux works too)
Ruby 1.9.3p0
GHC 7.4.1
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:
Building a haskell interpreter (hint) as dynamic library, useable from C++: Missing Interpreter.dyn_hi
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!
Related
I run an installation of GitLab on my ArchLinux server. GitLab depends on charlock_holmes for ICU support. Every time I update my system, this support breaks, because my ICU version is newer than the one GitLab/charlock_holmes use.
I am not a ruby programmer but I have taken a look at the source code and found that the extension is just compiled against the current libicu. However, just following the upgrade guide executes bundle install which updates all the Gems. This does not build the extension again it seems.
In the end, after running an update, I get errors like this:
/home/git/gitlab/vendor/bundle/ruby/2.2.0/gems/activesupport-4.1.9/lib/active_support/dependencies.rb:247:in `require': libicui18n.so.53: cannot open shared object file: No such file or directory - /home/git/gitlab/vendor/bundle/ruby/2.2.0/extensions/x86-linux/2.2.0/charlock_holmes-0.6.9.4/charlock_holmes/charlock_holmes.so (LoadError)
This is to be expected:
$ pacman -Q icu
icu 54.1-1
I am now looking for way to simply perform an additional step when upgrading to a new version that will compile the charlock_holmes version against the new libicu. As long as nothing major changes in these releases that requires charlock_holmes to be updated first, this shouldn't be a problem, should it?
Just spent a while figuring this out so here you go.
I'm assuming installation paths used in the GitLab guide. Please note that I am not a Ruby developer and I have no idea if this is the correct way to do it but it works for me.
If you're using a version of Ruby other that 2.2.0, please fix that. The same goes for the charlock_holmes version.
rm -rf /home/git/gitlab/vendor/bundle/ruby/2.2.0/extensions/x86_64-linux/2.2.0/charlock_holmes-0.6.9.4
sudo -u git -H bundle exec gem install charlock_holmes -- --with-icu-dir=/usr/lib/icu
I'm trying to install Ruby on Rails on Solaris 10 box. I managed to build Ruby 1.9.3 from source and I installed gems but when I run gem command every time I get this message:
# gem list
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
This is really anoying :)
So I tried to rebuild Ruby and here is what I noticed in the output of make.
configuring psych
libyaml is missing. Please install libyaml.
Failed to configure psych. It will not be installed.
I found the extconf.rb script that checks for that and I tried to run it manually:
# pwd
/root/pub/ruby-1.9.3-p194/ext/psych
#
# irb --simple-prompt
>> require 'mkmf'
=> true
>> find_header 'yaml.h'
checking for yaml.h... yes
=> true
>> find_library 'yaml', 'yaml_get_version'
checking for yaml_get_version() in -lyaml... yes
=> true
>> exit
Apparently extconf.rb could find libyaml but make could not. So I'm puzzled why make does not find it. Any thoughts?
There are a couple of walk-throughs online regarding the install of Rails on Solaris.
This is for Rails 3: https://www.machine-unix.com/2011/05/installing-rails3-on-solaris-10-910/
And this one talks about avoiding issues with incompatible libraries: http://www.nowastedmoves.com/2009/geekery/installing-ruby-on-rails-on-solaris-10-1008-2/
I've never tried this on Solaris, but hopefully this will be of help.
I had this problem with Mac OS, perhaps it helps: http://icodeapps.net/?p=8
You need to install libyaml.
If you're install libyaml from a pre-built package, you will likely need a separate package with development headers, usually "libyaml-dev" or similar.
Alternatively you can install libyaml from source:
Download the source package:
http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz. To build and install LibYAML, run:
$ ./configure
$ make
# make install
(Note the last line begins with a #, indicated a root shell, prepend sudo when running as a normal user.)
Then reconfigure and recompile Ruby after installing libyaml.
When I build a project with gcc, I can use the very useful -I flag to specify additional include dirs. Sometimes, gems require code to be compiled, but I can't use the -I flag. Specifically, I can't build RMagick on my machine because it fails on the MagickWand step:
checking for wand/MagickWand.h... no
I know exactly where MagickWand.h is. How do I tell gem where to find it?
UPDATE:
I have two versions of ImageMagick on my system (for work) and gem throws this error:
Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
/a/Magick-config reports version 6.5.8 Q8 is installed in [a]
/b/Magick-config reports version 6.6.4 Q16 is installed in [b]
Using 6.5.8 Q8 from [a].
gem is using version [a] whereas I want it to use version [b]...but I can't find any way to have it switch to [b]. As far as I can tell, gem doesn't consult my $PATH.
The guides indicate that like you can pass build options
If an extension fails to compile during gem installation the gem specification is not written out, but the gem remains unpacked in the repository. You may need to specify the path to the library’s headers and libraries to continue. You can do this by adding a – between RubyGems’ options and the extension’s build options:
$ gem install some_extension_gem
[build fails]
Gem files will remain installed in /path/to/gems/some_extension_gem-1.0 for inspection.
Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out
$ gem install some_extension_gem -- --with-extension-lib=/path/to/lib
[build succeeds]
$ gem list some_extension_gem
*** LOCAL GEMS ***
some_extension_gem (1.0)
$
For you, that sounds like gem install rmagick -- -I /path/to/MagickWand.h but I'm not really sure how to try it out to verify.
I'm getting the following error when I start rails server:
$ rails server
/Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2.rb:7:in `require': dlopen(/Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2- 0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-
0.2.6/lib/mysql2/mysql2.bundle
I've installed mysql2 with the following command after the rvm use ruby-1.9.2-p0 command:
$ gem install mysql2 -- --with-mysql-dir=/usr/local/mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql2-0.2.6
1 gem installed
Installing ri documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Client not known
Installing RDoc documentation for mysql2-0.2.6...
Enclosing class/module 'mMysql2' for class Client not known
I have mysql2 in my Gemfile as well as in the database.yml file and bundle install completes fine
$ bundle show mysql2
/Users/ssmith/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6
I understand the rails server error is due to it not knowing the mysql_config location on OSX, however on gem install I specified the correct location. Yet RVM's gem is not respecting that mysql_config location it seems.
Anyone have a solution to this?
The problem comes from the mysql2 gem missing the dynamic library from MySQL.
A cleaner solution than install_name_tool ... would need to update your DYLD_LIBRARY_PATH to add MySQL libs to it. To do so, update your ~/.bash_profile to add the MySQL library folder :
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
Note: You might want to update the MySQL location based on your install
This should keep things clean but also ensure that any gem or code requiring MySQL dynamic libraries will find them.
Reference : http://lightyearsoftware.com/2011/02/mysql-5-5-on-mac-os-x/
Reference Update July 2012: A change in OS X 10.8 makes the easy method above less elegant. If you set that variable, every time you run a setuid or setgid program, you get this warning on stderr:
dyld: DYLD_ environment variables being ignored because main executable (...) is setuid or setgid
Ruby developers using Phusion Passenger Standalone will see this message displayed in their console every five seconds. It gets really irritating, very fast.
I have filed a bug with Apple. It’s also at OpenRadar.
In the meantime, there is also a third way to fix the client library path problem that doesn’t require setting DYLD_LIBRARY_PATH (working around this 10.8 issue) or hacking .bundle files with install_name_tool:
$ brew install mysql
I found the answer here: Mysql 5.5, Snow leopard and rails
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
On OS X 10.8 (Mountain Lion), the listed answers all have issues, as noted in the answers and comments.
Setting DYLD_LIBRARY_PATH to include /usr/local/mysql/lib gives warnings from OS X and from brew
Using install_name_tool to hack where the gem binary looks would need to be redone each time the gem is installed or upgraded.
Switch to brew's mysql may not work; and in any case I don't want to reconfigure an already-working installation
A simpler and robust solution IMHO is to put a link to the library in the default dynamic library search path, which conveniently includes /usr/local/lib. That is:
ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib
Bill,
Frederic's answer will solve this problem, however you may have to change some of the items in the command depending on versions and how things are named on your system.
For example, on the most recent version of mysql libmysqlclient.16.dylib is actually libmysqlclient.18.dylib. Try doing a:
locate libmysqlclient.18.dylib
If that does not return the path you can go to:
/usr/local/{your-mysql}/lib
to find the file. Then just a PWD to find the correct directory for the command.
You will also need to determine what the actual package names of the rubies you have installed are. You can find this by using
rvm info
For example, my installation of 1.9.2 is ruby-1.9.2.p180, not ruby-1.9.2p0. This will need to be changed in Frederics command as well.
So, for me Frederic's command became for fixing the rvm rubies for 1.8.7 and 1.9.2, respectively:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.8.7-p334/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql-5.5.10-osx10.6-x86_64/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
below via: http://lightyearsoftware.com/2011/02/mysql-5-5-on-mac-os-x/
Update July 2012:
A change in OS X 10.8 makes the easy method above less elegant. If you set that variable, every time you run a setuid or setgid program, you get this warning on stderr:
dyld: DYLD_ environment variables being ignored because main executable (...) is setuid or setgid
Ruby developers using Phusion Passenger Standalone will see this message displayed in their console every five seconds. It gets really irritating, very fast.
I have filed a bug with Apple. It’s also at OpenRadar.
In the meantime, there is also a third way to fix the client library path problem that doesn’t require setting DYLD_LIBRARY_PATH (working around this 10.8 issue) or hacking .bundle files with install_name_tool:
$ brew install mysql
I was stuck on this for a while and came to a different solution.
Notice how the missing library is version 16:
Library not loaded: libmysqlclient.16.dylib (LoadError)
Turns out I had version 20 of that library - libmysqlclient.20.dylib
I correctly had gem 'mysql2' in my Gemfile, but what I needed to do was uninstall the gem, gem uninstall mysql (I had multiple versions of the gem installed) and then doing a new bundle install to get just the version I needed of this library.
After that it looked for - and found - the correct version of that lib.
Mine was in a different location, I had to use:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle.
Upgraded mysql to latest version and reinstall mysql2 gem works to me
brew upgrade mysql
gem uninstall mysql2
gem install mysql2
BTW: My MySQL version is 5.7.18, mysql2 gem version is 0.4.5
Here is what I do (similar to others)
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.10/lib/mysql2/mysql2.bundle
I'm getting this erron when trying to install RedCloth on openSuse:
sudo gem install RedCloth
Building native extensions. This could take a while...
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make
sh: make: nie znaleziono polecenia
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3/ext/redcloth_scan/gem_make.out
I tried to google this out and triend everything. So I need help with that.
I just had this same a similar problem and fixed it by installing the ruby dev package. For me, the command was:
sudo apt-get install ruby1.9.1-dev
I found the answer (and a better description of the problem) on this blog.
It's not the answer to this question exactly, but hopefully it'll be of use to someone else who stumbles upon this page.
If Google's Polish translation is correct, then you don't have make installed on your machine.
Try entering which make. If you see nothing, then you need to handle that first. I'm not sure the name of the package you need in OpenSuse. You should be able to search in Yum (Yast? whatever OpenSuse's package manager is called...) for something like Debian's 'build-essential' package.
Edit: In OpenSuse, the package you need seems to be called "C/C++ Development" (or "C/C++ Compiler and Tools"). See this thread for some pointers: http://forums.opensuse.org/applications/413553-build-essential.html
I don't know OpenSuse, but if it's anything like Debian, you can probably also install Ruby gems (and Perl and Python modules) directly from your package manager. This can be good and bad. Good because the package manager takes better care of dependencies and uninstalling (on average) than you would on your own. Bad because the distro will often have older versions than you might be able to get yourself. Still, it's an option to consider.
If using Windows and RubyInstaller.org, I believe you need to install the devkit they provide.
If you have make after checking with which make and you are sure you have ruby installed by checking which ruby it could be that you had installed something similar to sudo apt-get install ruby1.9.1-dev and then changed your mind and removed that because now you use rbenv or rvm or just installed from source. The problem is that the reference to /var/lib/ruby/1.9.1/ will still be associated with ruby gem and will try to install the gems there. Solution could be to remove that directory sudo rm -rf /var/lib/ruby/1.9.1/ and that could fix the issue.