RubyCocoa and libxml-ruby-0.3.6

i have two versions of Ruby with my computer, the default Tiger one
(1.8.2) and another one installed in /usr/local

i’ve buil recently RubyCocoa using the ruby in /ur/local

however, within XCode when i print out ruby --version, i still get the
Tiger’s one (1.8.2)

then, following an advice given on RubyCocoa-talk i’ve installed also
libxml-ruby-0.3.6 for the Tiger’s ruby.

each time i put a “require ‘xml/libxml’” i my “rb_main.rb” file i get an
error saying this Tiger’s ruby is unable to find that extension.

in order to install libxml-ruby-0.3.6 for the Tiger’s ruby i had to
install also rubygems.

if i make a test, using Tiger’s ruby, from the command line i get no
error the libray is found.

it is only when wanting to use it from XCode, in a RubyCocoa app i get
this error.

any idae ???

Use DarwinPorts to install ruby which will put yet another ruby
in /opt/local/bin but this will be easy to keep updated, again with
DarwinPorts, then use DarwinPorts to install RubyCocoa. It puts
everything
where it should be.

john

John N. Alegre [email protected] wrote:

Use DarwinPorts to install ruby which will put yet another ruby
in /opt/local/bin but this will be easy to keep updated, again with
DarwinPorts, then use DarwinPorts to install RubyCocoa. It puts everything
where it should be.

obviously we could also rubygems with darwinports ?

i’ll try taht asap thanks :slight_smile:

Une bévue wrote:

obviously we could also rubygems with darwinports ?

I do, and it has worked very well… Although, I haven’t been able to
install libxml-ruby using RubyGems. It can’t find the libiconv installed
by DarwinPorts. When I have some time to write up my problem, I’ll post
it to the list.

Regards,
Craig

On Mar 7, 2006, at 9:12 PM, Craig D. wrote:

Une bévue wrote:

obviously we could also rubygems with darwinports ?

I do, and it has worked very well… Although, I haven’t been able
to install libxml-ruby using RubyGems. It can’t find the libiconv
installed by DarwinPorts. When I have some time to write up my
problem, I’ll post it to the list.

Regards,
Craig

I made a libxml-ruby portfile for DarwinPorts. It has been in
bugzilla for about 2 weeks – maybe I should start bugging them on
the mailing list. They also haven’t looked at my mod_ruby update (all
it does it update the version and md5 checksum).

– Daniel

Une bévue [email protected] wrote:

do you know some workaround ?

i did a :

rm -rf /opt/local/lib/ruby/gems

followed by a :

~/Darwinports%> sudo port install rb-rubygems
—> Activating rb-rubygems 0.8.11_0
—> Cleaning rb-rubygems

then everything, up to now, worked fine.

Une,

Do you use any other ports? How many?

/opt/local is ONLY used by DP so you have the option of blowing
away /opt/local (sudo rm -rf /opt/local) reinstalling ports and then
reinstalling any ports you use.

On the issue of your scripts still finding /usr/bin/ruby, it is
necessary to
put in your .pofile in your home directrory “export
PATH=/opt/local/bin:/opt/local/sbin:$path”
This will make ports found first. If you use fink too do this AFTER you
call the fink script.

Good luck
john

Craig D. [email protected] wrote:

I do, and it has worked very well… Although, I haven’t been able to
install libxml-ruby using RubyGems.

unfortunately, this isn’t my case :wink:

because, before to darwinports i had allready installed rubygems into
/opt/local i get the following error message at the activate step :
—> Activating rb-rubygems 0.8.11_0
Error: Target com.apple.activate returned: Image error:
/opt/local/lib/ruby/gems/1.8/cache/sources-0.0.1.gem already exists and
does not belong to a registered port. Unable to activate port
rb-rubygems.
Error: /opt/local/bin/port: Status 1 encountered during processing.

do you know some workaround ?

John N. Alegre [email protected] wrote:

Use DarwinPorts to install ruby which will put yet another ruby
in /opt/local/bin but this will be easy to keep updated, again with
DarwinPorts, then use DarwinPorts to install RubyCocoa. It puts everything
where it should be.

i not sure about that, having done a complete re-install of ruby,
rubgems and rubycocoa i still get from my rb_main.rb where i’ve put :

def rb_main_init
path = OSX::NSBundle.mainBundle.resourcePath.fileSystemRepresentation
rbfiles = Dir.entries(path).select {|x| /.rb\z/ =~ x}
rbfiles -= [ File.basename(FILE) ]
which_ruby=which ruby .chomp
p “#{which_ruby}”
p #{which_ruby} --version
p $LOAD_PATH
rbfiles.each do |path|
require( File.basename(path) )
end
end

the print out is :

“/usr/bin/ruby”
“ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]\n”

still Tiger’s ruby…

however the $LOAD_PATH is :
[“/Users/yvon/work/RubyCocoa/BookmarksMerge/build/Development/BookmarksM
erge.app/Contents/Resources”,
“/Library/Frameworks/RubyCocoa.framework/Versions/A/Resources/ruby”,
“/opt/local/lib/ruby/site_ruby/1.8”,
“/opt/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.5.0”,
“/opt/local/lib/ruby/site_ruby”, “/opt/local/lib/ruby/vendor_ruby/1.8”,
“/opt/local/lib/ruby/vendor_ruby/1.8/powerpc-darwin8.5.0”,
“/opt/local/lib/ruby/vendor_ruby”, “/opt/local/lib/ruby/1.8”,
“/opt/local/lib/ruby/1.8/powerpc-darwin8.5.0”, “.”]

then again, again and again, ruby is tiger’s one even the $LOAD_PATH of
it is the corect one : /opt/local/blahblah…

exactly what i’ve get before using a “handy” install…

something wrong, to me, here !

John N. Alegre [email protected] wrote:

Do you use any other ports? How many?

no, only those related to ruby.

/opt/local is ONLY used by DP so you have the option of blowing
away /opt/local (sudo rm -rf /opt/local) reinstalling ports and then
reinstalling any ports you use.

yes i know.

On the issue of your scripts still finding /usr/bin/ruby, it is necessary to
put in your .pofile in your home

i think you mean .profile ?
-------------------^-----

or, does exist a .portfile file ?
--------------------^^----

i think this has been done automatically by the Darwinports pkg :

cat .profile

Your previous .profile (if any) is saved as .profile.dpsaved

Setting the path for DarwinPorts.

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

directrory “export
PATH=/opt/local/bin:/opt/local/sbin:$path”
This will make ports found first. If you use fink too do this AFTER you
call the fink script.

no i don’t use fink.

BUT, i wonder about the useness of .profile, is this used by XCode ?
i don’t think so.
also, i’m using zsh instead of bash as a shell.
my $PATH is obviously starting by /opt/local/bin :

echo $PATH
/opt/local/bin:/usr/local/bin:/usr/local/mysql/bin:/bin:/usr/bin:/sbin:/
usr/sbin:/usr/X11R6/bin:/Users/yvon/bin:/Developer/qt/bin:/usr/local/pgs
ql/bin:/Users/yvon/bin/groovy/bin

my ruby scripts does have a shebang like that :

#!/usr/bin/env ruby -w

then, when launching a ruby script from Terminal i get the right ruby
according to the $PATH

all of those scripts are working correctly, from Terminal.

again, i don’t think XCode nor RubyCocoa use this way to find ruby (thru
$PATH)

Jonathan Paisley (on RubyCocoa-talk mail-list) said something like “ruby
cocoa don’t use /opt/local/bin/ruby” it finds that by $LOAD_PATH, which
is correct.

Finally may be it is MY way to print-out which ruby is in under use
being WRONG (from XCode /RubyCocoa) :
which_ruby=which ruby .chomp
p “#{which_ruby}”
p #{which_ruby} --version
p $LOAD_PATH

because i don’t know, in the XCpde/RubyCocoa context, what’s the SHELL
in use (i’ve set the $SHELL to /usr/local/bin/zsh.

to finish with, adding this line (after p $LOAD_PATH) in my rb_main.rb :
p ruby --version
i get :
“ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0]\n”

now, i’ll try, before (re)+ installing ruby and co, try a libxml binder
install by gem.

On Mar 7, 2006, at 23:38, Une bévue wrote:

BUT, i wonder about the useness of .profile, is this used by XCode ?
i don’t think so.

Nope. It only affects what you get when you type “ruby” at the command
line.

again, i don’t think XCode nor RubyCocoa use this way to find ruby
(thru
$PATH)

I had the same problem. Somebody told me to use DarwinPorts, but
happily, I didn’t take their advice. The last thing I needed was yet
another install of Ruby in yet another location. I already had too many
installs as it was! {chuckle}

Look and see if you have too many RubyCocoa.framework files. I’ll bet
you’ll find one in /Library/Frameworks, AND one in
~/Library/Frameworks. Delete the one in your user Library, and XCode
should start finding the one you want.

Your making this much harder then needed. If you use DP to install
RubyCocca then the stuff that XCode uses goes in the correct developer
directories and the bindings go in /opt/local. This is all transparent
to
XCode! The need for the $PATH changes only have to do with using ruby
from
a shell.

This has been posted to both this list and the DP list.

install ruby with DP
install RubyCocca with DP
use RubyCocca in XCode
done

Dave H. [email protected] wrote:

I had the same problem. Somebody told me to use DarwinPorts, but
happily, I didn’t take their advice. The last thing I needed was yet
another install of Ruby in yet another location. I already had too many
installs as it was! {chuckle}

i agree very much with you, the ruby Darwinports install is worst than
the “hand made”.

the /opt/local/bin/gem is unable to find iconv (re-installed by dp) and
then fails to install ruby-libxml…

generally i avoid using dp nor fink…

Look and see if you have too many RubyCocoa.framework files. I’ll bet
you’ll find one in /Library/Frameworks, AND one in
~/Library/Frameworks. Delete the one in your user Library, and XCode
should start finding the one you want.

i don’t have a ~/Library/Frameworks even.

On Mar 8, 2006, at 9:43 AM, Une bévue wrote:

the /opt/local/bin/gem is unable to find iconv (re-installed by dp)
and
then fails to install ruby-libxml…

generally i avoid using dp nor fink…

The DP ruby applies several patches to ruby so you get a full working
install. If you are having trouble installing ruby-libxml through
rubygems, than download the tar.gz package, and run extconf with the
–with-iconv-dir=/usr option, or you can wait until darwinports
accepts my Portfile for libxml-ruby. Managing packages without the
use of a package manager is a pain in the ass.

– Daniel

John N. Alegre [email protected] wrote:

Your making this much harder then needed. If you use DP to install
RubyCocca then the stuff that XCode uses goes in the correct developer
directories and the bindings go in /opt/local.
i didn’t said the contrary…
This is all transparent to
XCode! The need for the $PATH changes only have to do with using ruby from
a shell.

i know that.

This has been posted to both this list and the DP list.

install ruby with DP
install RubyCocca with DP
use RubyCocca in XCode
done

it’s what i have done yesterday afternoon, however i was unable to
install libxml-ruby :
sudo gem install -r libxml-ruby
fails to :
ERROR: While executing gem … (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in
/opt/local/lib/ruby/gems/1.8/gems/libxml-ruby-0.3.6 for inspection.

even if iconv has been installed by dp…

then i’m BACK exactly at the point where i was before yesterday
afternoon, it is even worst because now i’m no more able to install
libxml-ruby which was the ONLY reason for me to make a new ruby install
with dp…

before that dp install i was able to use libxml-ruby from terminal,
RubyCocoa failed on “require ‘xml/libxml’”.

Daniel H. wrote:

The DP ruby applies several patches to ruby so you get a full working
install. If you are having trouble installing ruby-libxml through
rubygems, than download the tar.gz package, and run extconf with the
–with-iconv-dir=/usr option, or you can wait until darwinports
accepts my Portfile for libxml-ruby. Managing packages without the
use of a package manager is a pain in the ass.

Both from a thread on the DP list and the experience of at least two
fellow
programmers, all those problems are due to trying to put DP Ruby /
RubyCocca on top of some installation of the same. If you blow
away /opt/local and all of the installed RC frameworks, (you did do a
check
of all files installed when you installed RC didn’t you?) then use DP
install ruby (which also creates a /opt/local tree with all the Ruby
libs
and then use DP to install RC, you are there. The parts of RC that
depend
on Ruby libs will find those because the are under the same /opt/local
tree. No need to seach for ruby-libxml or any other dependent library.
RC
will know where to find them.

john

Daniel,

I would strongly encouage you to do this. They are pretty good.
Looking at
the various threads I am seeing about 50 percent of people who fail in
the
install of RubyCocca with DP and all of them have to do with the
ruby-libxml stuff. I wonder why it is a some do some dont?

john

Daniel H. [email protected] wrote:

The DP ruby applies several patches to ruby so you get a full working
install. If you are having trouble installing ruby-libxml through
rubygems, than download the tar.gz package, and run extconf with the
–with-iconv-dir=/usr option

fine thanks it works* using :

ruby ext/xml/extconf.rb --with-iconv-dir=/usr
make
sudo make install

and right now i’ve uncommented “require ‘xml/libxml’” in my rb_main.rb
and i don’t have any more crash about that, however i must test that
more deeply, this require works also from Terminal…

  • using rake fails into :
    ~/Desktop/libxml-ruby-0.3.6%> rake
    (in /Users/yvon/Desktop/libxml-ruby-0.3.6)
    rm -r html
    rm -r html
    rm -r pkg
    /usr/bin/ruby extconf.rb
    can’t find header files for ruby.
    rake aborted!
    Command failed with status (1): [/usr/bin/ruby extconf.rb]
    /Users/yvon/Desktop/libxml-ruby-0.3.6/rakefile:40
    (See full trace by running task with --trace)

then with trace :
~/Desktop/libxml-ruby-0.3.6%> rake --trace
(in /Users/yvon/Desktop/libxml-ruby-0.3.6)
** Invoke default (first_time)
** Invoke release (first_time)
** Invoke clobber (first_time)
** Invoke clean (first_time)
** Execute clean
rm -r cbg.o
rm -r libxml.o
rm -r ruby_xml_attr.o
rm -r ruby_xml_attribute.o
rm -r ruby_xml_document.o
rm -r ruby_xml_dtd.o
rm -r ruby_xml_input_cbg.o
rm -r ruby_xml_node.o
rm -r ruby_xml_node_set.o
rm -r ruby_xml_ns.o
rm -r ruby_xml_parser.o
rm -r ruby_xml_parser_context.o
rm -r ruby_xml_sax_parser.o
rm -r ruby_xml_schema.o
rm -r ruby_xml_tree.o
rm -r ruby_xml_xinclude.o
rm -r ruby_xml_xpath.o
rm -r ruby_xml_xpath_context.o
rm -r ruby_xml_xpointer.o
rm -r ruby_xml_xpointer_context.o
rm -r html
** Invoke clobber_doc (first_time)
** Execute clobber_doc
rm -r html
** Invoke clobber_package (first_time)
** Execute clobber_package
rm -r pkg
** Execute clobber
rm -r mkmf.log
rm -r Makefile
rm -r extconf.h
** Invoke update_version (first_time)
** Execute update_version
** Invoke compile (first_time)
** Invoke ext/xml/libxml.so (first_time)
** Invoke ext/xml/Makefile (first_time)
** Invoke ext/xml/extconf.rb (first_time, not_needed)
** Execute ext/xml/Makefile
/usr/bin/ruby extconf.rb
can’t find header files for ruby.
rake aborted!
Command failed with status (1): [/usr/bin/ruby extconf.rb]
/usr/lib/ruby/site_ruby/1.8/rake.rb:567:in sh' /usr/lib/ruby/site_ruby/1.8/rake.rb:566:in call’
/usr/lib/ruby/site_ruby/1.8/rake.rb:574:in sh' /usr/lib/ruby/site_ruby/1.8/rake.rb:657:in sh’
/usr/lib/ruby/site_ruby/1.8/rake.rb:652:in sh' /usr/lib/ruby/site_ruby/1.8/rake.rb:592:in ruby’
/usr/lib/ruby/site_ruby/1.8/rake.rb:657:in ruby' /usr/lib/ruby/site_ruby/1.8/rake.rb:652:in ruby’
/Users/yvon/Desktop/libxml-ruby-0.3.6/rakefile:40
/Users/yvon/Desktop/libxml-ruby-0.3.6/rakefile:39:in chdir' /Users/yvon/Desktop/libxml-ruby-0.3.6/rakefile:39 /Users/yvon/Desktop/libxml-ruby-0.3.6/rakefile:38:in call’
/usr/lib/ruby/site_ruby/1.8/rake.rb:232:in execute' /usr/lib/ruby/site_ruby/1.8/rake.rb:232:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:232:in execute' /usr/lib/ruby/site_ruby/1.8/rake.rb:202:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:195:in synchronize' /usr/lib/ruby/site_ruby/1.8/rake.rb:195:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:209:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:208:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:844:in send' /usr/lib/ruby/site_ruby/1.8/rake.rb:844:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:208:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:201:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:195:in synchronize' /usr/lib/ruby/site_ruby/1.8/rake.rb:195:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:209:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:208:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:844:in send' /usr/lib/ruby/site_ruby/1.8/rake.rb:844:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:208:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:201:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:195:in synchronize' /usr/lib/ruby/site_ruby/1.8/rake.rb:195:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:209:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:208:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:844:in send' /usr/lib/ruby/site_ruby/1.8/rake.rb:844:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:208:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:201:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:195:in synchronize' /usr/lib/ruby/site_ruby/1.8/rake.rb:195:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:209:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:208:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:844:in send' /usr/lib/ruby/site_ruby/1.8/rake.rb:844:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:208:in invoke_prerequisites' /usr/lib/ruby/site_ruby/1.8/rake.rb:201:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:195:in synchronize' /usr/lib/ruby/site_ruby/1.8/rake.rb:195:in invoke’
/usr/lib/ruby/site_ruby/1.8/rake.rb:1719:in run' /usr/lib/ruby/site_ruby/1.8/rake.rb:1719:in each’
/usr/lib/ruby/site_ruby/1.8/rake.rb:1719:in `run’
/usr/bin/rake:8
~/Desktop/libxml-ruby-0.3.6%>

John N. Alegre [email protected] wrote:

I wonder why it is a some do some dont?

the reason i didn’t use dp at first time is because i had really bad
experiment with dp (not for ruby install).

Daniel H. wrote:

They accepted the port. You may now install ruby-libxml with “port
install rb-libxml2” (don’t forget to sync, or selfupdate).

Did you tell them to include this in the dependencies for RubyCocoa?

john