2017-07-31 172 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脚本并尝试执行它,然后引发此奇怪的异常。

相关问题