Why does Ruby “script/generate” return “No such file or directory”?

不打扰是莪最后的温柔 提交于 2019-11-28 21:09:24

问题


I am having trouble using script/generate. I am following the tree based navigation tutorial, which says to use script/plugin install git://github.com/rails/acts_as_tree.git or script/generate nifty_layout.

I keep getting:

No such file or directory -- script/plugin

I've tried these variations:

script/generate nifty_layout
rails generate nifty_layout
ruby script/generate nifty_layout
ruby generate nifty_layout

and they all tell me:

-bash: script/generate: No such file or directory

Am I missing something? Total ruby nuby here and I just can't seem to find an answer.

edit: rails 3 on Mac OS X 10.6


回答1:


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




回答2:


There is a LOT of out-of-date information on the interwebs for Rails now as a result of it evolving quickly and being so popular. I use the Ruby on Rails Guides as my first stop for information as those pages seem to be the most current.

The rails generate info seems current.




回答3:


you may try a couple things, first, make sure since you are using rails 3 that you have run 'bundle install'. depending on how you installed rails and which version of bundler you are using, it may not be finding your rails binary to execute the rails generate .. so you may try prefixing it with bundle exec rails g but that is deprecated and you should get a warning if you call it. Also, make sure you are following ryan's instructions for rails 3 (and run bundle install once you add to the gemfile) on his library: https://github.com/ryanb/nifty-generators




回答4:


As a shortcut to rails server, you can use 'rails s'. Similarly for the console, 'rails c'.



来源:https://stackoverflow.com/questions/4320759/why-does-ruby-script-generate-return-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!