Ruby on Rails - Windows 7 上的新安装但无法运行 ruby 命令,路径有问题吗?
我刚刚在我的新计算机上安装了 ruby on Rails(我之前使用的是 instantrails),我正在尝试完成所有设置。
我运行的是 Windows 7。所以我按照本教程中的说明进行操作。
http://blogupstairs.com/ruby- on-rails/installing-ruby-on-rails-on-windows-7/
我猜问题是步骤 3
“将新安装的 bin 目录添加到 Windows 系统中的路径:打开 Windows 资源管理器- >右键单击计算机图标->在控制面板主页中选择“高级系统设置”,然后单击“环境变量”按钮->在系统变量中单击“新建”并添加新的系统变量,如下所示: : RUBY_HOME ,变量值: C:\Ruby,然后将其添加到路径中,并将分号后面的 bin 添加到“Path”变量,如下所示: C:\Program Files\Common Files\Adobe\AGL;%JAVA_HOME %\bin;%ANDROID_HOME%\tools;%RUBY_HOME%\bin"
我设置创建了系统变量,但是当我尝试在应用程序的主目录中运行 script/generate 时,出现错误
“Ruby:没有这样的文件或目录--script/generate”
我检查了应用程序目录,脚本文件夹就在那里。如何从控制面板运行“ruby script/generate”命令?
我猜测这是路径问题,但我不知道有什么方法可以检查以找出问题所在。
I just installed ruby on rails on my new computer ( I was using instantrails before) and I'm trying to get everything setup.
Im running Windows 7. So I followed the instructions from this tutorial.
http://blogupstairs.com/ruby-on-rails/installing-ruby-on-rails-on-windows-7/
The problem i'm guessing is step 3
"Add the newly installed bin directory to your path in your windows system : Open windows explorer-> right click the icon computer-> choose Properties -> in the contol panel Home, Click Advanced system settings and then click Envitonment Variables button->in the system variables click new and add new system variables like this : Variable name : RUBY_HOME , Variable Value : C:\Ruby, after that add it in to the path and add the bin after a semicolon to the “Path” variable like this : C:\Program Files\Common Files\Adobe\AGL;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%RUBY_HOME%\bin"
I set created the system variables but when I try to run script/generate in the main directory of my app I get the error
"Ruby: no such file or directory --script/generate"
I checked the apps directory and the script folder is in there. How can I run the "ruby script/generate" commands from the control panel?
I was guessing it was something with the path but I dont know any ways to check to find out whats going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您使用的是 Rails 3.0+ 吗?在此版本的 Rails 及更高版本中,script/* 文件夹已被弃用,取而代之的是
railsgenerate
、railsserver
等。请参阅 此处。Are you using Rails 3.0+? In this version of rails and up, the script/* folder has been deprecated in favor of
rails generate
,rails server
, etc. See here.在 99.99999% 的情况下,如果计算机告诉您在特定位置找不到文件,那是因为该文件不在该特定位置。
那么,当前目录中名为
script
的目录中是否真的存在一个名为generate
的文件?In 99.99999% of all cases, if a computer tells you that it cannot find a file at a specific location, it is because that file is not at that specific location.
So, is there actually a file named
generate
in a directory namedscript
in the current directory?我最近也在我的“干净”Win7 上安装了 RoR。
你使用什么IDE?
我建议尝试 JRuby 与 NetBeans/RubyMine:
系统环境设置中的路径
...,至于命令,正如 Nuclearsandwitch 提到的,Rails 3 中没有
script/generate
或script/server
。只需确保您在目录中你的 Rails 应用程序,然后尝试运行rails 服务器
它应该可以工作:-)。I have recently installed RoR on my "clean" Win7 as well.
What IDE are you using?
I suggest trying JRuby with NetBeans/RubyMine:
path
in system environment settings...,As for the commands, as Nuclearsandwitch mentioned, there is no
script/generate
orscript/server
in Rails 3. Just make sure you in the directory with your Rails app and then try runningrails server
. It should work :-)