Rails + Cassandra

I have an error installing gem cassandra.

sudo gem install cassandraBuilding native extensions. This could take
a while…ERROR: Error installing cassandra: ERROR: Failed to build
gem native extension. /usr/bin/ruby1.9.1 extconf.rbchecking for
strlcpy() in string.h… nocreating Makefile

makegcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/
ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -
D_FILE_OFFSET_BITS=64 -fPIC -g -O2 -Wall -Werror -o struct.o -c
struct.c

Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/
thrift-0.7.0 for inspection.

irb(main):001:0> reqire ‘cassandra’

NoMethodError: undefined method reqire' for main:Object from (irb):1 from /usr/bin/irb:12:in

irb(main):001:0> require ‘thrift’
=> true

What’s wrong?

On Dec 7, 2011, at 12:39 PM, Dandy wrote:

struct.c

Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/
thrift-0.7.0 for inspection.

It seems likely that you don’t have all the build tools installed or in
your user’s PATH.

irb(main):001:0> reqire ‘cassandra’

NoMethodError: undefined method reqire' for main:Object from (irb):1 from /usr/bin/irb:12:in

Mis-spelled require.

irb(main):001:0> require ‘thrift’
=> true

require works, so your Ruby is at least partially working then,

What’s wrong?

What’s your environment, and what steps have taken you to this point?
It’s impossible to guess at this stage. Are you able to compile and
install other applications from the command line with this user?

Walter

Require Cassandra

irb(main):001:0> require ‘cassandra’
LoadError: no such file to load – cassandra
from internal:lib/rubygems/custom_require:29:in require' from <internal:lib/rubygems/custom_require>:29:inrequire’
from (irb):1
from /usr/bin/irb:12:in `’

My gem list

$ gem list

*** LOCAL GEMS ***

actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
ansi (1.4.1)
arel (2.2.1)
builder (3.0.0)
bundler (1.0.21)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.1.3)
erubis (2.7.0)
execjs (1.2.9)
haml (3.1.3)
haml-rails (0.3.4)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.18)
json (1.6.3, 1.6.1)
libv8 (3.3.10.4 x86-linux)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.4, 1.0.3)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
railties (3.1.3)
rake (0.9.2.2)
rdoc (3.11)
sass (3.1.10)
sass-rails (3.1.5)
simple_uuid (0.2.0)
slayer-thrift (0.7.0)
sprockets (2.0.3)
sqlite3 (1.3.4)
therubyracer (0.9.9)
thor (0.14.6)
thrift (0.8.0)
tilt (1.3.3)
treetop (1.4.10)
turn (0.8.2)
tzinfo (0.3.31)
uglifier (1.1.0)

I think that error in the gem thrift_client, because …

~$ sudo gem install thrift_client -v ‘0.7.1’

Building native extensions. This could take a while…
ERROR: Error installing thrift_client:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for strlcpy() in string.h… no
creating Makefile

make
gcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/
ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -
fPIC -g -O2 -Wall -Werror -o protocol.o -c protocol.c
gcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/
ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -
fPIC -g -O2 -Wall -Werror -o struct.o -c struct.c
<…>

make: *** [struct.o] Error 1

So what is your build environment? Which compiler is installed, what
version of Linux is this, are you running it inside a VM or anything odd
like that? It sounds like you have ruby and rubygems installed fine, but
you don’t have the compiler or your environment set correctly to build
anything that is processor-native. Ruby code per se is cross-platform,
since it’s an interpreted language. But anything in a gem that needs
lower-level access to the hardware will often have to call out to a
cross-compiler and create and link some C code or similar. That’s where
your environment is breaking down, from what I have seen. When you get
that part working, you will be in better shape to use gem to install
these more “binary” gems.

Walter

Ubuntu 11.10

I’m using Ubuntu, Ruby (1.9.3) installed by RVM

On 8 December 2011 21:01, Dandy [email protected] wrote:

Ubuntu 11.10

Unfortunately you have lost all the context by not quoting the
previous messages, but if I remember correctly you are having problems
building the native extensions. Try, in a terminal,

sudo apt-get install build-essential bison openssl libreadline6
libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf

If you want to use mysql then also
sudo apt-get install libmysql-ruby libmysqlclient-dev

and if you want to use nokigirii
sudo apt-get install libxslt-dev libxml2-dev

The above might install a few things you do not need but they should
not do any harm.

In addition, if you are using rails 3 you need not install the gems
manually, just make sure they are included in Gemfile and do
bundle install
to install them.

Colin

On Dec 8, 2011, at 4:08 PM, Colin L. wrote:

On 8 December 2011 21:01, Dandy [email protected] wrote:

Ubuntu 11.10

Unfortunately you have lost all the context by not quoting the
previous messages, but if I remember correctly you are having problems
building the native extensions. Try, in a terminal,

sudo apt-get install build-essential bison openssl libreadline6
libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev
libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev autoconf

Before you do that, be sure to run

sudo apt-get update

…first, and let it do whatever it wants to do. I have wasted many
minutes when I forget to do that first.

Walter

[email protected] ~ $ sudo gem search cassandra --remote

*** REMOTE GEMS ***

activerecord-cassandra-adapter (0.1.0)
cassandra (0.12.1)
cassandra-cql (1.0.2)
cassandra-jars (1.0.0 java)

Try search for name.
If that exist, but you cannot install.
you need to update ruby gems.
and then you can be install gem

and then if you cannot install it.
Please install its dependency
See its dependency by below command

[email protected] ~ $ sudo gem dependency cassandra --remote
Gem cassandra-0.12.1
json (>= 0)
rake (>= 0)
simple_uuid (>= 0.2.0)
thrift_client (>= 0.7.0)

Gem cassandra-cql-1.0.2
bundler (>= 1.0.0, development)
rake (>= 0.9.2, development)
rcov (>= 0.9.9, development)
rspec (>= 2.6.0, development)
simple_uuid (>= 0.2.0)
thrift_client (>= 0.7.1)
yard (>= 0.7.2, development)

Gem cassandra-model-0.2.4
cassandra (>= 0, development)
shoulda (>= 0, development)

Gem cassandra_client-0.3
json (>= 0)

Gem cassandra_mapper-0.0.1
cassandra (>= 0)
mocha (>= 0, development)
rake (>= 0, development)
shoulda (>= 0, development)
simple_mapper (>= 0)
tzinfo (>= 0)

I would try

rvm get head

that will update RVM to the latest. Then

rvm install 1.9.2

I know you have it installed, but do it again to get the latest version.
Then:

git update --system

Then

gem install cassandra

And then read, parse, and act on the results of that last command. If it
says something like, “Install failed, install log is here with the
results of that failure” then locate and read that install log. Try to
take each error one at a time, and resolve it. You may have to go back
to the gem install cassandra line many, many times, once per thing you
change from the install errors log.

This part of compiling software is often compared to shaving a yak. Fun?
Not really. If you need a shiny yak, then essential.

Walter

I recently started learning Rails and I’m sorry for my English (I live
in Moscow) =)
The Russian Rails Group of developers to me no one could help …

Initialy, I installed Ubuntu 11.10, then updated apt-get.
Next, install the RVM and Ruby.

Cassandra has installed the following instructions:
http://blog.wolfgang-vogl.com/?p=140

How do I link my application on Rails 3 and Cassandra?

Thank you all!

sudo rvm get head
Original installed RVM version:
rvm 1.10.0-pre by Wayne E. Seguin ([email protected]) [https://
rvm.beginrescueend.com/]
remote: Counting objects: 340, done.remote: Compressing objects: 100%
(277/277), done.remote: Total 340 (delta 25), reused 193 (delta
20)Receiving objects: 100% (340/340), 810.58 KiB | 744 KiB/s,
done.Resolving deltas: 100% (25/25), done.From
git://github.com/wayneeseguin/rvm +
62631e5…db09ec1 master -> origin/master (forced update)HEAD is
now at db09ec1 do not force changing ruby on gemdir, fix #631
RVM: Shell scripts enabling management of multiple ruby
environments. RTFM: https://rvm.beginrescueend.com/ HELP:
http://webchat.freenode.net/?channels=rvm (#rvm on
irc.freenode.net) Upgrading the RVM installation in /usr/share/ruby-
rvm/ Correct permissions for base binaries in /usr/share/ruby-rvm/
bin… Copying manpages into place.RVM system user group ‘rvm’
exists, proceeding with installation. Recording config files for
rubies.
root,
If you have any questions, issues and/or ideas for improvement
pleasefork the project and issue a pull request.
If you wish to disable the project .rvmrc file functionality,
setrvm_project_rvmrc=0 in either /etc/rvmrc or ~/.rvmrc.
NOTE: To Multi-User installers, please do NOT forget to add your users
to the ‘rvm’ group. The installer no longer auto-adds root or users
to the rvm group. Admins must do this. Also, please note that group
memberships are ONLY evaluated at login time. This means that users
must log out then back in before group membership takes effect!
Thank you for using RVM!
I sincerely hope that RVM helps to make your life easier and more
enjoyable!!!
~Wayne

Upgrade Notes

  • rvm_trust_rvmrcs has been changed to rvm_trust_rvmrcs_flag for
    consistency
  • Project rvmrc files are now checked for trust whenever they
    change, as promised by the note displayed during the review process
  • Ruby package dependency list for your OS is given by: rvm
    requirements
  • If you encounter any issues with a ruby ‘X’ your best bet is to:
    rvm get head && rvm reinstall X
  • If you see the following error message: Unknown alias name:
    ‘default’ re-set your default ruby, this is due to a change in how
    default works.
  • after_use and after_cd hook now supports multiple files with
    after__ the custom hooks can be easily turned on/off by:
    chmod +x /usr/share/ruby-rvm/hooks/after_cd_[hook_name] chmod -x /
    usr/share/ruby-rvm/hooks/after_use_[hook_name]
  • If your shell exits on entering directory with freshly checked out
    sources you should update .rvmrc file, and replace any exit with
    return.

Upgrade of RVM in /usr/share/ruby-rvm/ is complete.

Installed RVM HEAD version:
rvm 1.10.0-pre by Wayne E. Seguin ([email protected]) [https://
rvm.beginrescueend.com/]
RVM reloaded!

NEXT:

$ sudo rvm install 1.10.0
rbx-1.10.0 installing #dependencies
Cloning git://github.com/rubinius/rubinius.git
Copying from repo to source…
rbx-1.10.0 - #configuring
rbx-1.10.0 - #compiling
rbx-1.10.0 - adjusting #shebangs for (erb ri rdoc).
rbx-1.10.0 - #importing default gemsets (/usr/share/ruby-rvm/gemsets/)

$ git update --system
git: ‘update’ is not a git command. See ‘git --help’.

Did you mean this?
update-ref

AND:

$ sudo gem install cassandra
Building native extensions. This could take a while…
ERROR: Error installing cassandra:
ERROR: Failed to build gem native extension.

/usr/bin/ruby1.9.1 extconf.rb
checking for strlcpy() in string.h… no
creating Makefile

make
gcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/
ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -
fPIC -g -O2 -Wall -Werror -o protocol.o -c protocol.c
gcc -I. -I/usr/include/ruby-1.9.1/i686-linux -I/usr/include/ruby-1.9.1/
ruby/backward -I/usr/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -
fPIC -g -O2 -Wall -Werror -o struct.o -c struct.c
struct.c:28:1: : static- <> static-

/usr/include/ruby-1.9.1/ruby/missing.h:157:20: :
<>
make: *** [struct.o] 1

Gem files will remain installed in /var/lib/gems/1.9.1/gems/
thrift-0.7.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/thrift-0.7.0/ext/
gem_make.out

On Dec 9, 2011, at 4:00 PM, Dandy wrote:

RVM: Shell scripts enabling management of multiple ruby
If you wish to disable the project .rvmrc file functionality,

  • If you see the following error message: Unknown alias name:
    Upgrade of RVM in /usr/share/ruby-rvm/ is complete.
    Cloning git://github.com/rubinius/rubinius.git
    Copying from repo to source…
    rbx-1.10.0 - #configuring
    rbx-1.10.0 - #compiling
    rbx-1.10.0 - adjusting #shebangs for (erb ri rdoc).
    rbx-1.10.0 - #importing default gemsets (/usr/share/ruby-rvm/gemsets/)

$ git update --system
git: ‘update’ is not a git command. See ‘git --help’.

Sorry, I meant

gem update --system

Not git…

Walter

On Dec 19, 2011, at 11:38 AM, Dandy wrote:

$ sudo gem update --systemERROR: While executing gem …
(RuntimeError) gem update --system is disabled on Debian, because
it will overwrite the content of the rubygems Debian package, and
might break your Debian system in subtle ways. The Debian-supported
way to update rubygems is through apt-get, using Debian official
repositories.If you really know what you are doing, you can still
update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment
variable, but please remember that this is completely unsupported by
Debian.

Wow. How much control do you have over this server? Can you remove the
Debian gem package and re-install gem from source? My sysadmin skills
are limited to Mac OS X Server, Solaris, and Ubuntu, so I don’t have any
more specific advice for you there. If you can, I would take everything
off – gem, Ruby, everything except the build tools basically. Then use
the RVM installer to install Ruby and gem in one go. Here’s my (Ubuntu)
recipe for that (do all of this as root):

aptitude safe-upgrade
aptitude update
aptitude install build-essential openssl libreadline6 libreadline6-dev
curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0
libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev
ncurses-dev automake libtool bison subversion libcurl4-openssl-dev
apache2 apache2-dev apache2-prefork-dev libapr1-dev libaprutil1-dev
mysql-server mysql-dev
(preceding should be all one line, naturally)

bash < <(curl -sk
https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

log out and back in

rvm install 1.9.2
rvm default 1.9.2

gem update --system
gem install passenger
(follow instructions from the installer)

passenger-install-apache2-module
(follow instructions from the installer)

If you don’t have aptitude, you can substitute apt-get for it where
noted above, I have used them interchangeably in the past.

Walter

$ sudo gem update --systemERROR: While executing gem …
(RuntimeError) gem update --system is disabled on Debian, because
it will overwrite the content of the rubygems Debian package, and
might break your Debian system in subtle ways. The Debian-supported
way to update rubygems is through apt-get, using Debian official
repositories.If you really know what you are doing, you can still
update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment
variable, but please remember that this is completely unsupported by
Debian.

On Mon, Dec 19, 2011 at 8:54 AM, Walter Lee D.
[email protected]wrote:

Debian.
aptitude update

(follow instructions from the installer)

If you don’t have aptitude, you can substitute apt-get for it where noted
above, I have used them interchangeably in the past.

I second the suggestion to use RVM instead of the debian packages for
ruby
and rubygems. I’ve generally found the packages to be problematic with
a
lot of newer gems. I read a while ago that the people who maintain the
Debian ruby packages are essentially unsupported and few in number, so
updates to those packages are very infrequent. I think they basically
said
not to expect a Debian package for 1.9.2 anytime soon.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs