my dog learned polymorphism*
The moose likes Ruby and the fly likes Can't start with Ruby on Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Can Watch "Can New topic
Author

Can't start with Ruby on Windows

Alwin Smith
Greenhorn

Joined: Aug 31, 2010
Posts: 4
I've installed Ruby 1.9.2 (standard installation) and Rails 3.0 on Windows XP. The ruby installation path is C:\Ruby192. I am trying to follow the first few steps of generating a web application in the directory C:\rubydev:

1. rails new hello
2. cd hello
3. ruby script/generate controller App

The first two commands work fine. But, whenever I execute the 3rd command, I get the following error:

ruby: No such file or directory -- script/generate (LoadError)

I've checked the environment variable "PATH" it includes "C:\Ruby192\bin" which, I've verified, is the directory containing "ruby.exe". Even if I write the third command as "C:\Ruby192\bin\ruby.exe script/generate controller App" still I get the same error.

Executing the command "ruby -v" gives the following output on my machine:
ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

Please tell me if there are any environment variables to be created or modified or if the installation is to be done in any special manner to make this stuff work.

Thanks in advance,
Tyro
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How about trying to use the actual Windows path separator character, which is "\", not "/"?

Oh, and welcome to JavaRanch! Please see the JavaRanch naming policy and change your display name to conform with this policy. Thanks!
Alwin Smith
Greenhorn

Joined: Aug 31, 2010
Posts: 4
David Newton wrote:How about trying to use the actual Windows path separator character, which is "\", not "/"?


I 've tried doing that. The command "ruby script\generate controller App" gives the same error message.

I tried to install ruby even on Ubuntu 10.04. And that gives the same error message. I'm attaching the snaphot of the terminal window with relevant commands along with this post.


Well, thanks for pointing out, I've updated my screen name as per the Ranch's policy.


[Thumbnail for ruby trial term.jpg]

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Ugh, please post text for text stuff, not screenshots :(

I've never seen this on Unix-like systems. Just as a sanity check, did you look in the script folder to make sure they're actually there?

Hmm... I do vaguely remember running into something like this once. I'd probably just ask on the rails user list.
Alwin Smith
Greenhorn

Joined: Aug 31, 2010
Posts: 4
David Newton wrote:did you look in the script folder to make sure they're actually there?


I looked into the script folder of the newly created dummy app (/home/alwin/rubydev/hello/script). It had just one file named "rails". The content of the file is as under:

_________________________________________________________________________________________________________
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.

APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
_________________________________________________________________________________________________________

Is there something wrong in the way I'm trying to use ruby. I tried a simple "Hello World" ruby program and it is running.
My program (hello.rb):
_________________
print "Hello World\n"
_________________

After saving it at desktop, I gave the following command, and it worked:

~/Desktop$ ruby hello.rb
(output: Hello World)

please advise how can I create a dummy web application using ruby and rails. I am trying to follow the book "Beginning Ruby on Rails" by "Steven Holzner" (Wrox series from Wiley). But I'm getting the same error message on all the platforms that I've tried.

Thanks
Alwin
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
I think that in Rails 3 the scripts are run using the rails command rather than ruby script/<scriptname>.

Try this and report back if you're still getting an error message:

rails generate controller App
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Oh, sorry, completely missed that you're using Rails 3--that's correct.

Make sure you're using Rails 3 docs to work with Rails 3, otherwise you're headed down a pretty long road!
Alwin Smith
Greenhorn

Joined: Aug 31, 2010
Posts: 4
Thanks Katrina and David,

I've found a more up to date resource for learning the framework. Now I'm referring to railstutorial.org.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Seeing all the hype about RoR, i was interested in learning it.
So, the story so far:
downloaded binary installer, followed steps to install it.
Error: script/controller no such directory exists.

Downloaded Aptana RadRails.
Error: rails needs RubyGem 1.3.2 you have RubyGem 1.3.1 (No Idea why they couldnt include 1.3.2 if it was needed.)

Downloaded RubyMine.
Error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require': 126: The specified module could not be found. - C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2.rb:7:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2.rb:7:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
from C:/Users/santu/RubymineProjects/Hello/config/application.rb:7:in `<top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'



Searched guzillion forums.No answers.
More than anything else, i think the RoR Distribution is poorly maintained. If sql3.dll is required, why isn't it bundled with the installer?
Just disappointed.
Easy to learn language is difficult to get started.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
Hi there, sorry to hear that you've been having trouble getting started!

Easy to learn language is difficult to get started.


To clarify, Ruby on Rails is not a language -- the language is ruby and rails is a framework.

The two packages you attempted to use are both maintained separately from rails itself.

You really don't need an IDE to write ruby/rails -- have you tried just using a text editor in order to get started? It might be less frustrating.

When you say that you downloaded the binary installer, what installer was it?

Here's how I got started with ruby and rails:

Installed the ruby language.
Installed rubygems.
Used rubygems to install rails (gem install rails)

I've never worked on a windows machine, so I am not familiar with the issues that crop up there, unfortunately.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
I've never worked on a windows machine, so I am not familiar with the issues that crop up there, unfortunately.


No wonder you are a happy Person.
Well, in the 36th hour of installing it.(haven't slept)
This time, i'm installing it the cygwin way.
Let's hope i'll be able to start working in a few mins.
I'm on windows 7 professional system.
Tried to install from Ruby Installer 1.9.2
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
Good luck with cygwin -- that's the way I would go if I had to get this working on windows!
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Finally!!
well, not what anybody would expect me to come up eith after struggling so much.
But, i found an awesome Rails Installer for Windows.
Got me working in 2 mins.Only if i knew it ><
But on the other hand, this experience has motivated me to install centOS on my system.It is a good idea in the long term.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
Also, if anybody faced same problem, please note:

syntax for generateing controller is not ruby script/generate controller

I created Hello application.So, the syntax for me was:
C:\RubyDev\Hello>Rails g controller hello

Now, maybe we know why I could not get started with Rubyinstaller
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1364
    
  17
Glad to hear you got it working!

A note on the syntax difference you found: it looks like you just ran into the difference between rails 2 and rails 3 -- rails has undergone a huge overhaul lately.

It's worth knowing which you are working with, so you can compare that to whatever they say they are using in the tutorials and articles you use/read.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
A note on the syntax difference you found: it looks like you just ran into the difference between rails 2 and rails 3 -- rails has undergone a huge overhaul lately.

That line sums up everything.
In a way its better....we check each method carefully thereby understanding more than we would.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't start with Ruby on Windows