我正在研究2.0.2 rails应用程序。现在,当我使用rake db:migate
从Windows PC执行命令时,它会Errno::ENOEXEC in SystemsController#index
。
还有其他方法可以从Windows PC上的rails应用程序执行系统命令吗?
这是错误:
Errno::ENOEXEC in SystemsController#index
Exec format error - rake db:migrate
RAILS_ROOT: E:/RoR/ibt/InstantRails-2.0-win/rails_apps/config
Application Trace | Framework Trace | Full Trace
E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``' ``
E:/RoR/ibt/InstantRails-2.0-win/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'`
app/controllers/systems_controller.rb:24:in `index'
我正在使用ruby控制台:
irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1
Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config
11/29/2012 03:11 PM <DIR> .
11/29/2012 03:11 PM <DIR> ..
11/29/2012 02:41 PM <DIR> app
11/29/2012 02:42 PM <DIR> config
=> true
irb(main):002:0> system('rake db:migrate')
=> false
irb(main):003:0>
答案 0 :(得分:0)
我已经通过从rake所在的批处理文件中运行rake文件解决了这个问题。
irb(main):001:0> system('dir')
Volume in drive E has no label.
Volume Serial Number is 522C-BDB1
Directory of E:\RoR\ibt\InstantRails-2.0-win\rails_apps\config
11/29/2012 03:11 PM <DIR> .
11/29/2012 03:11 PM <DIR> ..
11/29/2012 02:41 PM <DIR> app
11/29/2012 02:42 PM <DIR> config
=> true
irb(main):002:0> system('rake db:migrate')
=> false
在控制器文件中
system("#{RAILS_ROOT}/../../ruby/bin/rake.bat db:migrate")
给出结果
== 99 AddFieldtoSystemAssoziations: migrating =================================
== 99 AddFieldtoSystemAssoziations: migrated (0.0391s) ========================