为什么 Ruby 会“脚本/生成”?返回“没有这样的文件或目录”?
我在使用 script/generate
时遇到问题。我正在遵循 基于树的导航 教程,该教程表示使用 script /plugin install git://github.com/rails/acts_as_tree.git
或 script/generate nifty_layout
。
我不断得到:
没有这样的文件或目录——脚本/插件
我尝试过这些变体:
script/generate nifty_layout
rails generate nifty_layout
ruby script/generate nifty_layout
ruby generate nifty_layout
它们都告诉我:
-bash:脚本/生成:没有这样的文件或目录
我错过了什么吗?这里完全是红宝石努比,我似乎找不到答案。
编辑:Mac OS X 10.6 上的 Rails 3
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Rails 3 是你的问题(或者更确切地说是问题的原因)。自 Rails 3 起,所有“script/whatever”命令都已替换为“railswhatever”。
所以现在你想要“rails generated ...”或“rails server”。
查看教程时请务必查看版本号或发布日期:)
连锁:
Rails 3 中缺少 script/generate
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
由于 Rails 发展迅速且非常流行,现在互联网上有很多过时的信息。我使用 Ruby on Rails 指南 作为我获取信息的第一站,因为这些页面似乎是最新的。
railsgenerate
信息似乎是最新的。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.你可以尝试一些事情,首先,确保因为你使用的是 Rails 3,所以你已经运行了“bundle install”。根据您安装 Rails 的方式以及您使用的捆绑程序版本,它可能找不到您的 Rails 二进制文件来执行
railsgenerate ..
,因此您可以尝试在它前面加上bundle execrails 前缀g
但这已被弃用,如果您调用它,您应该收到警告。另外,请确保您遵循 ryan 在他的库上针对 Rails 3 的说明(并在添加到 gemfile 后运行捆绑安装): https://github.com/ryanb/nifty-generatorsyou 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 withbundle 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作为 Rails 服务器的快捷方式,您可以使用“rails s”。对于控制台,“rails c”也是如此。
As a shortcut to rails server, you can use 'rails s'. Similarly for the console, 'rails c'.