[英]Syntax Error when trying to run rails runner on test environment
I created a script to be run with rails runner. 我创建了一个脚本以与RailsRunner一起运行。 I tested it locally and it worked just fine, but on a remote server (it's deployed to AWS) it throws the following error:
我在本地对其进行了测试,但效果很好,但是在远程服务器(已部署到AWS)上,它会引发以下错误:
/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
Full error message here: 完整的错误消息在这里:
/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>'
Any idea which the problem might be? 知道可能是什么问题吗?
You need to execute the command like this: 您需要执行以下命令:
rails runner script/content_update.rb
Where script/content_update.rb
is the correct path to your script. 其中
script/content_update.rb
是script/content_update.rb
的正确路径。
When you specify it like /script/content_update.rb
Rails
searches it in a wrong location and can't find it. 当您像
/script/content_update.rb
这样指定它时, Rails
在错误的位置搜索它并找不到它。 When the file is not found, Rails
treats the string as a Ruby
script and tries to execute it, and then raises this strange exception. 当找不到该文件时,
Rails
将字符串视为Ruby
脚本并尝试执行它,然后引发此奇怪的异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.