script/generate not working ! while rails do

Hi Strange thing happens when i run rails project it makes project but when i run script/generate or script/server it writes

Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

so rails -v gives Rails 2.3.5

How to fix that kind of problem ? i use mac and my "gem environment" is

RubyGems Environment:   - RUBYGEMS VERSION: 1.3.5   - RUBY VERSION: 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]   - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8   - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby   - EXECUTABLE DIRECTORY: /usr/bin   - RUBYGEMS PLATFORMS:     - ruby     - universal-darwin-9   - GEM PATHS:      - /Library/Ruby/Gems/1.8      - /Users/boris/.gem/ruby/1.8

What does the environment.rb show as the rails version?

Chris Habgood wrote:

What does the environment.rb show as the rails version?

# Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION

Hi Strange thing happens when i run rails project it makes project but when i run script/generate or script/server it writes

Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

so rails -v gives Rails 2.3.5

I can't help much not being a mac man, but I believe that this can happen if rails is installed twice in different places. Google for 'missing the rails gem' might help.

Colin

Colin Law wrote:

Hi Strange thing happens when i run rails project it makes project but when i run script/generate or script/server it writes

Missing the Rails 2.3.5 gem. Please `gem install -v=2.3.5 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

so rails -v gives Rails 2.3.5

I can't help much not being a mac man, but I believe that this can happen if rails is installed twice in different places. Google for 'missing the rails gem' might help.

Colin

Exactly, i have 1.2.3 1.2.6 installed to /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 and 2.3.5 version here /Library/Ruby/Gems/1.8

don't know what default is - i guess it's /Library/Ruby/Gems/1.8

i removed files from that directory /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 but it didn't help. So in file "server" (script/server) we have 2 lines of code

#!/usr/bin/env ruby require File.expand_path('../../config/boot', __FILE__) require 'commands/server'

first line load boot file and in booot file we have that line that loads gems

class GemBoot < Boot     def load_initializer       self.class.load_rubygems       load_rails_gem       require 'initializer'     end

    def load_rails_gem       if version = self.class.gem_version         gem 'rails', version       else         gem 'rails'       end     rescue Gem::LoadError => load_error       $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_$       exit 1     end

i am not an expert in ruby so far but i guess this function returns false "load_rails_gem" and this expression returns false "gem 'rails'" so it's a gem method but what it's doing ?

Can you post the output of 'gem list --local'? I'm guessing that you're missing one of the dependencies somehow.

--Matt Jones

Matt Jones wrote:

How to fix that kind of problem ? i use mac and my "gem environment" is

Can you post the output of 'gem list --local'? I'm guessing that you're missing one of the dependencies somehow.

--Matt Jones

gem list --local

*** LOCAL GEMS ***

actionmailer (2.3.5, 1.3.6, 1.3.3) actionpack (2.3.5, 1.13.6, 1.13.3) actionwebservice (1.2.6, 1.2.3) activerecord (2.3.5, 1.15.6, 1.15.3) activeresource (2.3.5) activesupport (2.3.5, 1.4.4, 1.4.2) acts_as_ferret (0.4.4, 0.4.1) capistrano (2.5.13, 2.0.0) cgi_multipart_eof_fix (2.5.0, 2.2) daemons (1.0.10, 1.0.9, 1.0.7) dnssd (1.3.1, 0.6.0) fastthread (1.0.7, 1.0.1, 1.0) fcgi (0.8.8, 0.8.7) ferret (0.11.6, 0.11.4) gem_plugin (0.2.3, 0.2.2) git (1.2.5) highline (1.5.1, 1.2.9) hpricot (0.8.2, 0.6) libxml-ruby (0.3.8.4) mongrel (1.1.4, 1.0.1) needle (1.3.0) net-scp (1.0.2) net-sftp (2.0.4, 1.1.0) net-ssh (2.0.17, 1.1.2) net-ssh-gateway (1.0.1) rack (1.0.1) rails (2.3.5, 1.2.6, 1.2.3) rake (0.8.7, 0.7.3) RedCloth (4.2.2, 3.0.4) ruby-openid (1.1.4) ruby-yadis (0.3.4) rubygems-update (1.3.5) rubynode (0.1.3) sources (0.0.1) sqlite3-ruby (1.2.1) termios (0.9.4)

gem dependency rails Gem rails-1.2.3   rake (>= 0.7.2, runtime)   activesupport (= 1.4.2, runtime)   activerecord (= 1.15.3, runtime)   actionpack (= 1.13.3, runtime)   actionmailer (= 1.3.3, runtime)   actionwebservice (= 1.2.3, runtime)

Gem rails-1.2.6   rake (>= 0.7.2, runtime)   activesupport (= 1.4.4, runtime)   activerecord (= 1.15.6, runtime)   actionpack (= 1.13.6, runtime)   actionmailer (= 1.3.6, runtime)   actionwebservice (= 1.2.6, runtime)

Gem rails-2.3.5   rake (>= 0.8.3, runtime)   activesupport (= 2.3.5, runtime)   activerecord (= 2.3.5, runtime)   actionpack (= 2.3.5, runtime)   actionmailer (= 2.3.5, runtime)   activeresource (= 2.3.5, runtime)

[snip]

Well, that was a wash. I don't see anything missing on the list; as others have noted, do you happen to have a second Ruby installed? Try running '/usr/bin/env ruby'.

--Matt Jones