Why does Ruby script/generate return No such file or directory?
Rails 3 is your problem (or rather the cause of). Since rails 3 all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want "rails generate ..." or "rails server" instead.
Be sure to watch version numbers or post dates when looking at tutorials :)
linkage:
Missing script/generate in Rails 3
Ruby Error: No such file or directory -- script/generate (LoadError)
If you are on rails 3 then the command is:
rails generate scaffold newtest name:string
Or the slightly shorter:
rails g scaffold newtest name:string
Notice rails not ruby.
Error: No such file or directory, when trying to execute [ruby script/generate]?
I think you are meaning to do rails generate
?
First create a new Rails app:
rails new random_app
cd random_app
rails generate scaffold post title:string body:text
When you "ruby" something, it looks for a file to execute.
Rails is the framework for abstraction and scaffolding.
See "Why does Ruby "script/generate" return "No such file or directory"?".
Rails 3 is the problem. Since Rails 3, all of the "script/whatever" commands have been replaced with "rails whatever".
So now you want rails generate ...
or rails server
instead.
Raise an error on Ruby/Script generate scaffold
You need to install bundler.
gem install bundler
and than
bundle install
after this you can generate scaffold
also look this
Ruby -s returns No such file or directory (switches)
You can only pass a single option to the command named in in the shebang line. Or truly spoken, if you pass multiple arguments, they will not get exploded but passed as single argument. In this case like:
/usr/bin/env 'ruby -s'
But the file 'ruby -s'
does not exist. That's why the error message.
Following the Ruby's man page, you are supposed do use the following shebang:
#! /usr/bin/ruby -s
# :prints "true" if invoked with `-xyz' switch.
print "true\n" if $xyz
You need to call ruby directly instead of using /usr/bin/env
. This is a drawback, but doing so, you can call the script like this:
./script.rb -xyz
Using gets() gives No such file or directory error when I pass arguments to my script
It looks like you want to the user to type some input by reading a line from STDIN
, the best way to do this is by calling STDIN.gets
and not gets
. So your line becomes:
word = STDIN.gets.chomp
This is documented as IO.gets
. STDIN
is an instance of IO
.
Right now, you're executing Kernel.gets
, which does something different (emphasis mine):
Returns (and assigns to $_) the next line from the list of files in ARGV (or $*), or from standard input if no files are present on the command line.
This appears to behave like STDIN.gets
if ARGV
is empty, but is not the same thing, hence the confusion.
ruby: No such file or directory -- puts (LoadError) on mac
The ruby executable expects a file name, e.g.:
$ ruby test.rb
ruby puts
tries to load a file named puts
, resulting in the error message.
Use the -e
switch to evaluate a single line / command:
$ ruby -e 'puts "Hello World"'
Hello World
Related Topics
Rails Email Error - 530-5.5.1 Authentication Required
How to Run Ruby on Rails with Ruby 1.9X
Openssl VS Gpg for Encrypting Off-Site Backups
How to Specify Local .Gem Files in My Gemfile
How to Export Environment Variable Permanently Using Ruby
How to Ruby on Rails Authentication with Ldap
Export Content of a SQLite3 Table in CSV
How to Submit Polymorphic Comments on Feed? [Error]
Unknown Ruby Interpreter Version (Do Not Know How to Handle): Ruby_Version
M Hartl's Ruby on Rails Tutorial Chapter 5 Custom Title on Home Page
How to Capitalize the First Letter in a String in Ruby
Rails 4: How to Reset Test Database
How to Use Ruby Dbi's 'Select_All' VS 'Execute-Fetch/Each-Finish'