Help getting into console

I need help getting into console. I could have sworn I did everything
right, but on 3 different computers I get the exact same error.

C:\rails_apps\test>ruby script/console
Loading development environment.
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_re quire': no such file to load -- ./script/../config/../config/environment (LoadEr ror) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inre
quire’
from c:/ruby/lib/ruby/1.8/irb/init.rb:252:in load_modules' from c:/ruby/lib/ruby/1.8/irb/init.rb:250:ineach’
from c:/ruby/lib/ruby/1.8/irb/init.rb:250:in load_modules' from c:/ruby/lib/ruby/1.8/irb/init.rb:21:insetup’
from c:/ruby/lib/ruby/1.8/irb.rb:54:in `start’
from c:/ruby/bin/irb.bat:20

I have ruby 1.8.5 installed on 2 of them and 1.8.6 on the third. I have
rails 1.2.3 installed on the 2 that have ruby 1.8.5 and rails 1.2.2 and
1.2.3 installed on the third one.

Here are the steps I took to get to this point.

  1. downloaded and installed ruby with Windows 1 click installer
  2. C:>gem install rails --include-dependencies
  3. C:>rails test
  4. C:>cd test
  5. C:\test>ruby script/console
  6. watch the error and cry myself to sleep.

Help would be awesome. thanks

~Jeremy

Shouldn’t that be ruby script\console when you’re on windows? (Notice
the backslash vs. the regular slash)

On 7/21/07, Jeremy W. [email protected] wrote:

ror)

  1. C:\test>ruby script/console


Obie F.

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619

Obie F. wrote:

Shouldn’t that be ruby script\console when you’re on windows? (Notice
the backslash vs. the regular slash)

On 7/21/07, Jeremy W. [email protected] wrote:

ror)

  1. C:\test>ruby script/console


Obie F.
Best Online Casino in Australia | Top Licensed Casinos for Gamblers

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619

It works either way.

Steve R. wrote:

Nope. Windows understands forward slashes. The error says it cant
find a file. I’m not sure if this is a truncated backtrace, but it
appears to be looking for “environment”. As I recall, you have to do
some goofing around to get the load paths working right in Windows.
Don’t suppose you could just reformat c: with Ubuntu, huh? Just kidding.

What happens when you do:

ruby script/server

??

script/server runs fine, both with Webrick and Mongrel installed.
script/generate works fine also. It is just the script/console. I
wouldn’t mind putting Ubuntu on my home computers, but I wouldn’t be
able to on my work computer. I convinced the company to let me write a
web application in rails because they do EVERYTHING in VB, but I feel
hindered by not being able to get into console.

One weird thing to note is that is you reassign the value of path when
it’s value is ./script/…/config/…/config/environment to “application”
then it will continue to load and then kick me into IRB. A friend of
mine says he thinks I might be missing a gem, but I installed all the
dependencies, I don’t know what other gems to install.

Rails version?

ruby script/about

A bit off topic, what I did on Windows was install cygwin. Is this an
option?

–s

Nope. Windows understands forward slashes. The error says it cant
find a file. I’m not sure if this is a truncated backtrace, but it
appears to be looking for “environment”. As I recall, you have to do
some goofing around to get the load paths working right in Windows.
Don’t suppose you could just reformat c: with Ubuntu, huh? Just kidding.

What happens when you do:

ruby script/server

??

This probably won’t help, but on XP I updated Rails to 1.2.3 and Ruby
is at 1.8.5. I created a fresh project, created a database, then a
migration and:

C:\rails\test\db\migrate>cd …/…

C:\rails\test>rake db:migrate
(in C:/rails/test)
== CreatePeople: migrating

– create_table(:people)
-> 0.0500s
== CreatePeople: migrated (0.0500s)

C:\rails\test>ruby script/console
Loading development environment.

p = Person.new
=> #<Person:0x47ff1d0 @new_record=true, @attributes={“name”=>nil,
“address”=>nil
}>

p.name = ‘bob’
=> “bob”

p.address = ‘123 main street’
=> “123 main street”

p.save
=> true

My Ruby-fu has deserted me this Sunday. I have a plugin that adds a
helper to ActionView. This is an abbreviated version of the init
code. When it’s included by sending a :include message to
ActionView::base, everything works as expected. In tests, however,
the “initializing module” is printed when the module is included in
the test class, but the class variables are not accessible after
that. Anyone have an idea why? (BTW: I’ve clearly misunderstood
what’s going on in the base.class_eval stuff. I thought I was adding
class variables – i.e. @@analytics_key – to whatever class mixed my
stuff in, and with ActionView::Base it works.)

the plugin (abbreviated)

module GoogleAnalyticsHelper
def self.included(base) #nodoc#
base.class_eval do
puts “initializing module”
no_analytics_key_message = ‘Add your analytics key with code
like GoogleAnalyticsHelper.analytics_key = “ZZ-NNNNNN-N”’
analytics_key = nil
analytics_base = <<-EOT
<script src=“http://www.google-analytics.com/urchin.js”,
type=“text/javascript” />

EOT
end
end
end

the test (abbreviated)

require ‘test/unit’
require File.dirname(FILE) + ‘/…/lib/google_analytics’

class GoogleAnalyticsTest < Test::Unit::TestCase
include GoogleAnalyticsHelper

def test_should_raise_exception_when_key_not_set
assert_raise {google_analytics}
end
end

I’ve always used Rails on windows,
it works just fine.

having run “rails test”
you should have a full application tree,
c:\test\app \config \test …

if you are in c:\test
running ruby “script/console”
literally runs the file “c:\test\script\console.rb”

that runs
#!/usr/bin/env ruby
require File.dirname(FILE) + ‘/…/config/boot’
require ‘commands/console’

and in turn “c:\test\config\boot.rb” will call environment.rb,
and such.

so it seems you’re getting past the first bit;
how about trying to run the console manually.

c:\test\irb

irb > require ‘config/environment’

this will manually invoke the rails environment.
If that doesn’t work, then hopefully it’ll give us some better errors,
else it may be something to do with environment variables.

It seems so incredibly unlikely that three different systems with
different versions of Ruby and of Rails could all be having the same
problem. Any chance you could totally remove Ruby and the gems on one
machine and install from scratch? I know it’s a pain, but I assure
you that a fresh install of Rails does work on Windows. I did just
try it.

If you really want to dig in and find the bad actor, then maybe you
should install ruby-debug and step through the code to see where the
settings are wrong. My guess is that scrubbing Ruby and the gems and
reinstalling is a better use of your time.

–s

Matthew R. wrote:

I’ve always used Rails on windows,
it works just fine.

having run “rails test”
you should have a full application tree,
c:\test\app \config \test …

if you are in c:\test
running ruby “script/console”
literally runs the file “c:\test\script\console.rb”

that runs
#!/usr/bin/env ruby
require File.dirname(FILE) + ‘/…/config/boot’
require ‘commands/console’

and in turn “c:\test\config\boot.rb” will call environment.rb,
and such.

so it seems you’re getting past the first bit;
how about trying to run the console manually.

c:\test\irb

irb > require ‘config/environment’

this will manually invoke the rails environment.
If that doesn’t work, then hopefully it’ll give us some better errors,
else it may be something to do with environment variables.

Thanks for the information. That was awesome. So it seems going into IRB
and require ‘config/environment’ works just fine. It returns true and I
can do my console stuff. So what now? maybe I need to go through the
files. As someone asked earlier about my versions…

I have 3 computers with the same problem.

  1. Windows XP PRO, Ruby 1.8.6 rails 1.2.3
  2. Windows XP PRO, Ruby 1.8.5 rails 1.2.3
  3. Windows XP PRO, Ruby 1.8.5 rails 1.2.2

to add:
C:\rails_apps\test>ruby script/about
About your application’s environment
Ruby version 1.8.5 (i386-mswin32)
RubyGems version 0.9.0
Rails version 1.2.3
Active Record version 1.15.3
Action Pack version 1.13.3
Action Web Service version 1.2.3
Action Mailer version 1.3.3
Active Support version 1.4.2
Application root C:/rails_apps/test
Environment development
Database adapter mysql
Database schema version 1

Here is my boot.rb file http://rafb.net/p/AagJHX25.html
It looks fine to me, but in case anyone out there notices anything weird
let me know.

Couple of things to try:

First… upgrade to 1.8.6 (or just work with the 1.8.6 machine first.

Next…

gem update --system

(that’s two dashes), This will get you the latest gems.

If that doesn’t fix your problem, check file permissions. Ensure that
you
are either running as an admin, or have granted appropriate rights to
yourself to read and execute from c:\ruby and all subfolders, and also
ensure you have access to your rails test app.

Let me know what you find out.