rsruby install trouble

  • Thread starter Guybrush Threepwood
  • Start date
G

Guybrush Threepwood

Hello, trying for no particular reason to create a K constant calculator
for chemical equilibrium for a chemical reaction. The way the experiment
was done, I need to put a best fit line on some data. R, and therefore,
RSRuby, seems like the best to do this (if I'm wrong, please enlighten),
but I cannot get RSRuby working. I'm using R 2.8.1 (I found something
which said R 2.9.x doesn't work well with rsruby, not sure on the
validity of that, but, whatever), Mac OS X 10.4.11, and what happens is
the following.

I unpack the R package, and it goes into /Library/Frameworks/

I downloaded the rsruby distro, and try to run setup as ruby setup.rb
config -- -with-R-dir=$R_HOME (regardless of whether I set R_HOME to the
right directory (the installer thing says the right one is
/Library/Frameworks/r.something/Resources) or whether I put that in for
dir= it fails) and I get an error message, as it says it cannot find the
R directory. The README gives three solutions. The first, to put
something in the .bashrc file in ~ doesn't work as I don't have a
bashrc file (must say OSX isn't my forte, don't know if that is in an
earlier/later OSX distro). The second is to link a file in the
/Library/Frameworks/etcetera... to /usr/lib/, which when done, does
nothing. The last also deals with a file that I don't see anywhere.

Point is, anyone know a) what I'm doing wrong or (preferably) b) an
easier way to do this?

P.S. Here is the output

/rsruby-0.5 root# ruby setup.rb config -- --with-R-dir=$R_HOME
---> lib
---> lib/rsruby
<--- lib/rsruby
<--- lib
---> ext
/usr/bin/ruby /rsruby-0.5/ext/extconf.rb
--with-R-dir=/Library/Frameworks/R.framework/Resources/
checking for main() in -lR... no

ERROR: Cannot find the R library, aborting.
setup.rb:655:in `command': system("/usr/bin/ruby"
"/rsruby-0.5/ext/extconf.rb"
"--with-R-dir=/Library/Frameworks/R.framework/Resources/") failed
(RuntimeError)
from setup.rb:660:in `ruby'
from setup.rb:1238:in `extconf'
from setup.rb:1230:in `config_dir_ext'
from setup.rb:1532:in `__send__'
from setup.rb:1532:in `traverse'
from setup.rb:1530:in `dive_into'
from setup.rb:1530:in `traverse'
from setup.rb:1524:in `exec_task_traverse'
from setup.rb:1519:in `each'
from setup.rb:1519:in `exec_task_traverse'
from setup.rb:1223:in `exec_config'
from setup.rb:991:in `exec_config'
from setup.rb:826:in `__send__'
from setup.rb:826:in `invoke'
from setup.rb:773:in `invoke'
from setup.rb:1578
 
A

Alex Gutteridge

Hello, trying for no particular reason to create a K constant calculator
for chemical equilibrium for a chemical reaction. The way the experiment
was done, I need to put a best fit line on some data. R, and therefore,
RSRuby, seems like the best to do this (if I'm wrong, please enlighten),
but I cannot get RSRuby working. I'm using R 2.8.1 (I found something
which said R 2.9.x doesn't work well with rsruby, not sure on the
validity of that, but, whatever), Mac OS X 10.4.11, and what happens is
the following.

I unpack the R package, and it goes into /Library/Frameworks/

[snip]


Point is, anyone know a) what I'm doing wrong or (preferably) b) an
easier way to do this?

Try the gem. This works for me with ruby 1.8.7, R 2.10.1 on OSX 10.6.4.
gem install rsruby --
--with-R-dir=/Library/Frameworks/R.framework/Resources/
Building native extensions. This could take a while...
Successfully installed rsruby-0.5.1.1
1 gem installed
Installing ri documentation for rsruby-0.5.1.1...
Installing RDoc documentation for rsruby-0.5.1.1...
 
G

Guybrush Threepwood

Okay, now I'm trying to install rubygems, but am getting a weird error
message for that. Do I have to pass it anything, or should it just be
ruby setup.rb in the directory where the files are?

(the error)

/lib/rubygems.rb:723:in `set_paths': uninitialized constant Gem::Etc
(NameError)
from ./lib/rubygems.rb:719:in `each'
from ./lib/rubygems.rb:719:in `set_paths'
from ./lib/rubygems.rb:526:in `path'
from ./lib/rubygems/source_index.rb:66:in
`installed_spec_directories'
from ./lib/rubygems/source_index.rb:56:in `from_installed_gems'
from ./lib/rubygems.rb:736:in `source_index'
from ./lib/rubygems/gem_path_searcher.rb:86:in `init_gemspecs'
from ./lib/rubygems/gem_path_searcher.rb:21:in `initialize'
from ./lib/rubygems.rb:684:in `new'
from ./lib/rubygems.rb:684:in `searcher'
from ./lib/rubygems.rb:683:in `synchronize'
from ./lib/rubygems.rb:683:in `searcher'
from ./lib/rubygems/custom_require.rb:34:in `require'
from /usr/lib/ruby/1.8/tmpdir.rb:12
from ./lib/rubygems/custom_require.rb:31:in
`gem_original_require'
from ./lib/rubygems/custom_require.rb:31:in `require'
from setup.rb:95
 
A

Alex Gutteridge

Okay, now I'm trying to install rubygems, but am getting a weird error
message for that. Do I have to pass it anything, or should it just be
ruby setup.rb in the directory where the files are?

(the error)

./lib/rubygems.rb:723:in `set_paths': uninitialized constant Gem::Etc
(NameError)
from ./lib/rubygems.rb:719:in `each'
from ./lib/rubygems.rb:719:in `set_paths'
from ./lib/rubygems.rb:526:in `path'
from ./lib/rubygems/source_index.rb:66:in
`installed_spec_directories'
from ./lib/rubygems/source_index.rb:56:in `from_installed_gems'
from ./lib/rubygems.rb:736:in `source_index'
from ./lib/rubygems/gem_path_searcher.rb:86:in `init_gemspecs'
from ./lib/rubygems/gem_path_searcher.rb:21:in `initialize'
from ./lib/rubygems.rb:684:in `new'
from ./lib/rubygems.rb:684:in `searcher'
from ./lib/rubygems.rb:683:in `synchronize'
from ./lib/rubygems.rb:683:in `searcher'
from ./lib/rubygems/custom_require.rb:34:in `require'
from /usr/lib/ruby/1.8/tmpdir.rb:12
from ./lib/rubygems/custom_require.rb:31:in
`gem_original_require'
from ./lib/rubygems/custom_require.rb:31:in `require'
from setup.rb:95

If you're on OSX you should already have rubygems (I think?). Your error
looks like it comes from having a <1.8.3 version of Ruby installed:

http://rubyforge.org/tracker/index.php?func=detail&aid=22313&group_id=126&atid=575
 
G

Guybrush Threepwood

Now I've gotten all this stuff working. The problem with getting the
right ruby and rubygems was I had an older version of xcode, but I got
the right one. So through macports I got ruby and rubygems, and through
rubygems I did the sudo install gem rsruby --
--with-R-dir=/Library/Frameworks/etcetera, and it installs correctly.
Problem is, when I type require 'rsruby' into irb (or put it into a
program), it doesn't know what it is. Do I have to hand it a path to
somewhere?
 
A

Alex Gutteridge

Now I've gotten all this stuff working. The problem with getting the
right ruby and rubygems was I had an older version of xcode, but I got
the right one. So through macports I got ruby and rubygems, and through
rubygems I did the sudo install gem rsruby --
--with-R-dir=/Library/Frameworks/etcetera, and it installs correctly.
Problem is, when I type require 'rsruby' into irb (or put it into a
program), it doesn't know what it is. Do I have to hand it a path to
somewhere?

Have you required rubygems first (you will need to on older version of
ruby)? E.g.
=> true
 
G

Guybrush Threepwood

Sorry, actually, I'm having one more issue. When I get to the section of
the program that calls R, it says "Fatal Error: R home directory is not
defined." I thought I saw something to the effect that I stick a line of
code in some file, but I do not remember what. Do you know what that is?
 
R

Ryan Davis

Sorry, actually, I'm having one more issue. When I get to the section of
the program that calls R, it says "Fatal Error: R home directory is not
defined." I thought I saw something to the effect that I stick a line of
code in some file, but I do not remember what. Do you know what that is?

IIRC, the readme will help with this and other issues that come up.
 
G

Guybrush Threepwood

As per the README, I stuck the line

"export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Library/Frameworks/R.framework/Resources/bin"

into my .bashrc file, but no such luck. As for the other two options, I
cannot find the ldconfig file is says to run after doing what it says.
As noted, I'm a total newbie when it comes to this stuff, so I'm
probably just making a dumb mistake somewhere.
 
A

Alex Gutteridge

Sorry, actually, I'm having one more issue. When I get to the section of
the program that calls R, it says "Fatal Error: R home directory is not
defined." I thought I saw something to the effect that I stick a line of
code in some file, but I do not remember what. Do you know what that is?

Assuming you are using Bash as your shell (I think it is the default in
OSX), to define R_HOME put

export R_HOME="/Library/Frameworks/R.Framework/Resources"

Into ~/.bashrc and source it / restart the terminal session. If you're
using a different shell then Google for how to set environment variables.
 
G

Guybrush Threepwood

Alex Gutteridge wrote in post #958443:
Assuming you are using Bash as your shell (I think it is the default in
OSX), to define R_HOME put

export R_HOME="/Library/Frameworks/R.Framework/Resources"

Into ~/.bashrc and source it / restart the terminal session. If you're
using a different shell then Google for how to set environment
variables.

Unfortunately, that didn't work either, as it still spits out the same
error. I tried it with and without the quotes, but in both cases it just
doesn't see it. Any other possibilities?
 
A

Alex Gutteridge

Alex Gutteridge wrote in post #958443:

Unfortunately, that didn't work either, as it still spits out the same
error. I tried it with and without the quotes, but in both cases it just
doesn't see it. Any other possibilities?

Type the following and show me your terminal output.

export R_HOME="/Library/Frameworks/R.framework/Resources/"
$R_HOME
irb
require 'rsruby'
RSRuby.instance

This is what I get:

GUTTEA$ export R_HOME="/Library/Frameworks/R.framework/Resources/"
GUTTEA$ $R_HOME
-bash: /Library/Frameworks/R.framework/Resources/: is a directory
GUTTEA$ irb=> #<RSRuby:0x101176ce8 @class_table={}, @default_mode=-1, @caching=true,
@cache={"get"=>#<RObj:0x101176810>, "helpfun"=>#<RObj:0x101172f80>,
"help"=>#<RObj:0x101172f80>, "NaN"=>NaN, "FALSE"=>false, "TRUE"=>true,
"F"=>false, "NA"=>-2147483648, "eval"=>#<RObj:0x1011752a8>, "T"=>true,
"parse"=>#<RObj:0x101175820>}, @proc_table={}>
 
G

Guybrush Threepwood

Deadpool:~ Sam$ export
R_HOME="/Library/Frameworks/R.framework/Resources/"
Deadpool:~ Sam$ $R_HOME
-bash: /Library/Frameworks/R.framework/Resources/: is a directory
Deadpool:~ Sam$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'rsruby'
=> true
irb(main):003:0> RSRuby.instance
=> #<RSRuby:0x48c9e8 @caching=true, @cache={"get"=>#<RObj:0x48c948>,
"helpfun"=>#<RObj:0x48c060>, "help"=>#<RObj:0x48c060>, "NaN"=>NaN,
"FALSE"=>false, "TRUE"=>true, "F"=>false, "NA"=>-2147483648,
"eval"=>#<RObj:0x48c614>, "T"=>true, "parse"=>#<RObj:0x48c6f0>},
@proc_table={}, @class_table={}, @default_mode=-1>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top