2017-07-31 159 views
0

我創建了一個腳本,以便與rails runner一起運行。我在本地測試,它工作得很好,但在遠程服務器上(它部署到AWS)它拋出以下錯誤:嘗試在測試環境中運行rails runner時出現語法錯誤

/home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1 
/lib/rails/commands/runner.rb:62: 
syntax error, unexpected tIDENTIFIER, expecting end-of-input 

完全錯誤的訊息:

/home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/runner.rb:62:in `eval': /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/runner.rb:62: unknown regexp options - rt (SyntaxError) 
/home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/runner.rb:62: syntax error, unexpected tIDENTIFIER, expecting end-of-input 
/script/content_update.rb 
          ^
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/runner.rb:62:in `<top (required)>' 
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/commands_tasks.rb:128:in `require' 
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/commands_tasks.rb:128:in `require_command!' 
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/commands_tasks.rb:95:in `runner' 
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!' 
    from /home/ubuntu/my-project/vendor/bundle/ruby/2.1.0/gems/railties-4.1.14.1/lib/rails/commands.rb:17:in `<top (required)>' 
    from bin/rails:4:in `require' 
    from bin/rails:4:in `<main>' 

任何想法,其中問題可能是?

回答

0

你需要這樣的執行命令:

rails runner script/content_update.rb 

哪裏script/content_update.rb是你的腳本的正確路徑。

當您指定它爲/script/content_update.rbRails在錯誤的位置進行搜索並找不到它。當找不到該文件時,Rails將該字符串視爲Ruby腳本並嘗試執行它,然後引發此奇怪的異常。

相關問題