I am getting a segmentation fault. Should which ruby return /usr/local/bin?
maletor$ rails generate mailer ContactMailer
/Users/maletor/.rvm/gems/ruby-1.9.2-p0/gems/mysql2-0.2.4/lib/mysql2/mysql2.bundle: [BUG] **Segmentation fault**
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
Abort trap
maletor$ which rails
/usr/bin/rails
maletor$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-darwin10.4.0]
- INSTALLATION DIRECTORY: /Users/maletor/.rvm/gems/ruby-1.9.2-p0
- RUBY EXECUTABLE: /Users/maletor/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/maletor/.rvm/gems/ruby-1.9.2-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/maletor/.rvm/gems/ruby-1.9.2-p0
- /Users/maletor/.rvm/gems/ruby-1.9.2-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => false
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "-n/usr/local/bin"
- REMOTE SOURCES:
- http://rubygems.org/
maletor$ echo $PATH
/Users/maletor/.rvm/gems/ruby-1.9.2-p0/bin:/Users/maletor/.rvm/gems/ruby-1.9.2-p0#global/bin:/Users/maletor/.rvm/rubies/ruby-1.9.2-p0/bin:/Users/maletor/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
maletor$ which gem
/Users/maletor/.rvm/rubies/ruby-1.9.2-p0/bin/gem
maletor$ ls ~/.rvm/rubies/ruby-1.9.2-p0/bin/
erb gem irb rake rdoc ri ruby testrb
maletor$ rails -v
Rails 3.0.0
maletor$ which rails
/usr/bin/rails
There's a problem with you RVM installation. which should return
/Users/maletor/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
Upgrade to the latest RVM installation. There was a bug in the 1.0 release with "shell path caching".
$ rvm get head
$ rvm reload
$ rvm repair all
$ rvm use 1.9.2
Related
I am trying to open rails console in production mode and it throws below error,
/usr/local/lib/ruby/1.9.1/rubygems.rb:340:in `bin_path':
can't find executable rails for rails-3.2.8 (Gem::Exception)
from /usr/local/bin/rails:19:in `<main>'
I have not used rvm. Other commands like rake:xyz runs properly. Output of $gem env is as follows,
RubyGems Environment:
RUBYGEMS VERSION: 1.3.7
RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-linux]
INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
RUBY EXECUTABLE: /usr/local/bin/ruby
EXECUTABLE DIRECTORY: /usr/local/bin
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/usr/local/lib/ruby/gems/1.9.1
/root/.gem/ruby/1.9.1
GEM CONFIGURATION:
:update_sources => true
:verbose => true
:benchmark => false
:backtrace => false
:bulk_threshold => 1000
REMOTE SOURCES:
http://rubygems.org/
Please let me know what needs to be. I cannot go for bundle install, etc as its production env and there are few tasks running. I dont want to break existing tasks / processes
It worked by using,
RAILS_ENV=production bundle exec rails c
Being a beginner,I have tried the same on my system and I got into the rails console.In fact my gem env resulted in
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.23
- RUBY VERSION: 1.9.3 (2013-11-22 patchlevel 484) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
- RUBY EXECUTABLE: /usr/bin/ruby1.9.1
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.9.1
- /home/mmohan/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
On reading the error, gem is found to be outdated. The best method to tackle it is by updating gem to latest one. If for assistance, check thishttp://www.coval.nl/blog/?p=18
I have an issue with a "missing gem".
After executing rake gems:install
>> rake gems:install
(in /some/path)
gem install google-api-client --version "= 0.7.1"
Successfully installed uuidtools-2.1.5
Successfully installed google-api-client-0.7.1
2 gems installed
Installing ri documentation for uuidtools-2.1.5...
Installing ri documentation for google-api-client-0.7.1...
Installing RDoc documentation for uuidtools-2.1.5...
Installing RDoc documentation for google-api-client-0.7.1...
Where we can see with a gem list the presence of the gem
>> gem list | grep google
google-api-client (0.7.1)
When starting my rail app I get a :
Missing these required gems:
google-api-client
You're running:
ruby 1.8.7.302 at /usr/bin/ruby1.8
rubygems 1.3.7 at /some/path/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8
and then Rails advices me to execute a "rake gems:install" to solve the issue..
I only have a single version of ruby installed : ruby 1.8.7-p302
>> which ruby
/usr/bin/ruby
>> ls -l /usr/bin/ruby
lrwxrwxrwx 1 root root 7 Aug 26 2013 /usr/bin/ruby -> ruby1.8
>> ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
>> gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/lib/ruby/gems/1.8
- /root/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I don't know where does the issue come from.
(Similarly, if I just make a ruby test file
require "rubygems"
require "google-api-client"
It outputs the same error :
>> ruby test.rb
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- google-api-client (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from test.rb:2
)
EDIT : I don't use bundle on this app.
Do you have some clue to solve this ?
Thanks !
Well, it was just the require that was erroneous
require "google/api_client"
instead of
require "google-api-client"
Thanks for the help.
You will update bundle version and then update gem.
I want to install rails 3.2.1 on ubuntu 11.10.
I already installed rbenv, ruby-build.
When I run
gem install rails
it tells me
Successfully installed rails-3.2.1
1 gem installed
Installing ri documentation for rails-3.2.1...
Installing RDoc documentation for rails-3.2.1...
then after rbenv rehash, if I run "rails", it cannot find the binary file. So I guess rails is NOT installed. How can I do?
edit:
~ » gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.15
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /home/jafar/.rbenv/versions/1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/jafar/.rbenv/versions/1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1
- /home/jafar/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
edit 2 :
gem list tells me the rails gem is installed. When I search for the rails binary I find this :
~ » find . -name rails
./.oh-my-zsh/plugins/rails
./Downloads/robbyrussell-oh-my-zsh-3629270/plugins/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/guides/code/getting_started/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/bin/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/app/templates/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/generators/rails/plugin_new/templates/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/engine_project/test/dummy/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/scss_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/test/fixtures/sass_project/script/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/sass/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-rails-3.2.4/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activerecord-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/actionmailer-3.2.1/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/jquery-rails-2.0.0/lib/jquery/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/sass-3.1.12/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/rails
./.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin/rails
The rails binary should be in ~/.rbenv/shims but it's not. ~/.rbenv/shims is in my PATH
You need to add the bin subdirectory of /home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1 to your PATH, e.g. edit your ~/.bashrc file and add this line at the end:
export PATH=/home/jafar/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bin:$PATH
And then see what the command rails --version will output.
My rails application is working well under my user:
$ rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on htttp://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-03-30 01:56:29] INFO WEBrick 1.3.1
[2011-03-30 01:56:29] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.7.0]
[2011-03-30 01:56:29] INFO WEBrick::HTTPServer#start: pid=3899 port=3000
But I need to run it under port 80, so running it as sudo gives me this:
$ sudo rails server -p 80
/Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin/rails:18:in `<main>'
More info:
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
$ sudo ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
$ rails -v
Rails 3.0.5
$ sudo rails -v
/Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:900:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:248:in `activate'
from /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems.rb:1276:in `gem'
from /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin/rails:18:in `<main>'
$ gem list --local rails
*** LOCAL GEMS ***
rails (3.0.5)
$ sudo gem list --local rails
*** LOCAL GEMS ***
rails (3.0.5)
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ sudo gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2011-02-18 patchlevel 180) [x86_64-darwin10.7.0]
- INSTALLATION DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- RUBY EXECUTABLE: /Users/jamez/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
- EXECUTABLE DIRECTORY: /Users/jamez/.rvm/gems/ruby-1.9.2-p180/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180
- /Users/jamez/.rvm/gems/ruby-1.9.2-p180#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Any idea of what's going on?
How can I make it work with and without sudo?
RVM is preventing sudo from seeing the Rails binary.
To get around this, use rvmsudo:
> rails -v
Rails 2.3.11
> sudo rails -v
/Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:214:in `activate'
from /Users/dan/.rvm/rubies/ree-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems.rb:1082:in `gem'
from /Users/dan/.rvm/gems/ree-1.8.7-2010.02#crm/bin/rails:18
> rvmsudo rails -v
Rails 2.3.11
You are using Rails 3, which uses Bundler, which installs gems on a per-user basis, so before you can run the app as a given user, you must first run bundle install while logged in as that user. I think that will make it work for you.
By the way, I assume you know that running anything as root is risky. You probably want to configure Apache and Passenger (or something like that) to serve up your Rails application over port 80.
I just upgraded my ubuntu from 9.10 to 10.04,
before the upgrade everything was fine, but after the upgrade I can no
longer run script/console.
Loading development environment (Rails 2.3.10)
/usr/local/lib/site_ruby/1.9.1/rubygems.rb:779:in
`report_activate_error':Gem::LoadError: RubyGem version error:
rails(2.3.4 not = 2.3.10)
/usr/lib/ruby/1.9.1/irb/init.rb:264:in `require':LoadError: no such file
to load -- console_app
/usr/lib/ruby/1.9.1/irb/init.rb:264:in `require':LoadError: no such file
to load -- console_with_helpers
# gem -v
1.5.2
# ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
# rails -v
Rails 2.3.10
Google was not much help so far :(
Update:
After trying several options, I updated to 10.10 and now getting following errors
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
$ gem -v
1.6.2
$ rails -v
Rails 2.3.10
$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.6.2
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /usr/local/lib/ruby/gems/1.9.1
- /home/recmend/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ whereis ruby
ruby: /usr/bin/ruby1.8 /usr/bin/ruby /usr/lib/ruby /usr/local/bin/ruby /usr/local/lib/ruby /usr/share/man/man1/ruby.1.gz
$ whereis gem
gem: /usr/bin/gem /usr/local/bin/gem
$ script/console
Loading development environment (Rails 2.3.10)
/usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:68:in `installed_spec_directories': undefined method `path' for Gem:Module (NoMethodError)
from /usr/local/lib/site_ruby/1.9.1/rubygems/source_index.rb:58:in `from_installed_gems'
from /usr/local/lib/site_ruby/1.9.1/rubygems.rb:883:in `source_index'
Off to next problem...
the problem is in your Rubies versions. You see:
$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i686-linux]
but
Loading development environment (Rails 2.3.10) /usr/local/lib/site_ruby/1.9.1/rubygems.rb:779:in
It is trying to load 1.9.1 with all its gems.
What you can do here.
which ruby will return your Ruby 1.9.2 dir
add it into your PATH export PATH=/your/ruby1.9.2/dir/bin:$PATH
enjoy :)