can't run script/console from ubuntu upgrade 9.10 -> 10.04 - ruby-on-rails

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 :)

Related

Ruby: Can't get gem to upgrade from 1.8.23 to 1.9.1 on Ubuntu 14.04

I'm just getting started with Ruby on Rails, so I apologize if I'm missing something horribly basic here...
Through some reading (and complaints from Rails), I've seen a lot of recommendations to install Ruby/Gem >v1.9. I upgraded whatever version Ruby was on my Ubuntu 14.04 machine to v1.9.3, but my version of Gem refuses to upgrade beyond 1.8.23.
The gem executable is labeled /usr/bin/gem1.9.1, but when you ask it for its version or dump the environment it returns 1.8.23. Rails seems to have installed fine with it as 1.8.23, but whines at me to upgrade whenever I generated a new project.
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
$ /usr/bin/gem1.9.1 -v
1.8.23
$ gem env
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/andy/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I installed ruby with sudo apt-get ruby-dev, which seems to be what folks are saying is correct for Ubuntu. At one point I tried sudo apt-get ruby-full, as recommended by ruby-lang.org but that didn't seem to work either.
I'm trying to make sure I set this up correctly, so I don't get too deep into development and realize I borked my environment from the get-go. Should I just give up on apt-get and install from source, or is there something else that I did wrong?
Thanks
Use rubygems-update:
gem install rubygems-update
update_rubygems
gem update --system

No such file to load / Missing these required gems

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.

Can start new rails 3.2 project after installing rails 4 beta

I installed rails 4 beta1 to try out. now, I am trying to create a new rails 3.2 app using rails version hack but it doesn't work.
$ gem list rails
*** LOCAL GEMS ***
rails (4.0.0.beta1, 3.2.13, 3.1.0)
$ rails -v
Rails 4.0.0.beta1
$ rails _3.2.13_ demo
/home/gaurish/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems.rb:317:in `bin_path': can't find gem rails (["3.2.13"]) with executable rails (Gem::GemNotFoundException)
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/rails:19:in `<main>'
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `eval'
from /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin/ruby_noexec_wrapper:14:in `<main>'
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.25
- RUBY VERSION: 2.0.0 (2013-02-24 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /home/gaurish/.rvm/gems/ruby-2.0.0-p0
- RUBY EXECUTABLE: /home/gaurish/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/gaurish/.rvm/gems/ruby-2.0.0-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/gaurish/.rvm/gems/ruby-2.0.0-p0
- /home/gaurish/.rvm/gems/ruby-2.0.0-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => 1
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-rdoc --no-ri --verbose"
- REMOTE SOURCES:
- http://rubygems.org/
what is wrong, how do I fix this so I can have both rails 4 & rails 3.2 installed at the same time?
Update your rubygems to 2.0.3
gem update --system
and don't panic! It's just Rails 3
rails _3.2.13_ new demo
Had the same problem earlier today.
Removing rails 4.0.0.beta1 and reinstalling it, then using rails _3.2.13__ as stated in your question solved the issue for me.

Error when running rails as root

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.

Rails Script Segmentation Fault with RVM

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

Resources