我正在实施一项非常基本的佣金任务:
filename lib / tasks / dosbis.rake
namespace :app do
desc "My first rake file"
task :dosbis => :environment do
end
end
当我使用以下命令执行时,我收到以下错误:
MacBook-Air-de-JCR:tasks jcr$ sudo bundle exec rake dosbis --trace
Password:
(in /Users/jcr/web/net/dos_prod)
/Users/jcr/web/net/dos_prod/lib/tasks/dosbis.rake:1: warning: encountered \r in middle of line, treated as a mere space
rake aborted!
SyntaxError: /Users/jcr/web/net/dos_prod/lib/tasks/dosbis.rake:1: syntax error, unexpected tIDENTIFIER, expecting keyword_end
... task :dosbis => :environment do
... ^
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `block in load'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:223:in `load'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:641:in `block in run_tasks_blocks'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:641:in `each'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:641:in `run_tasks_blocks'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/application.rb:244:in `run_tasks_blocks'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/engine.rb:446:in `load_tasks'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/railties-4.0.4/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/jcr/web/net/dos_prod/Rakefile:6:in `<top (required)>'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:687:in `raw_load_rakefile'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:93:in `load_rakefile'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:77:in `block in run'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'
/Users/jcr/.rvm/gems/ruby-2.1.1/bin/rake:23:in `load'
/Users/jcr/.rvm/gems/ruby-2.1.1/bin/rake:23:in `<main>'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/bin/ruby_executable_hooks:15:in `eval'
/Users/jcr/.rvm/rubies/ruby-2.1.1/lib/ruby/gems/2.1.0/bin/ruby_executable_hooks:15:in `<main>'
MacBook-Air-de-JCR:tasks jcr$
我非常感谢你的帮助。 谢谢
这是我的系统信息和rails和ruby的版本............
MacBook-Air-de-JCR:tasks jcr$ ls -l dosbis.rake
-rw-r--r-- 1 jcr staff 139 20 jul 22:06 dosbis.rake
MacBook-Air-de-JCR:tasks jcr$ pwd
/Users/jcr/web/net/dos_prod/lib/tasks
MacBook-Air-de-JCR:tasks jcr$
MacBook-Air-de-JCR:tasks jcr$ rails -v
Rails 4.0.4
MacBook-Air-de-JCR:tasks jcr$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0]
答案 0 :(得分:0)
你似乎有不可见的角色\r
。警告信息
在行中间遇到\ r \ n
建议这样做。
尝试让编辑器显示不可见的字符以查看不需要的字符。
答案 1 :(得分:0)
desc
必须与task
namespace :app do
desc "My first rake file"
task :dosbis => :environment do
end
end