thoughtbot / cocaine

A small library for doing (command) lines.
https://robots.thoughtbot.com
Other
785 stars 55 forks source link

Cocaine::ExitStatusError when I switch from paperclip-ffmpeg 1.0.1 to 1.2.0 #77

Closed casertap closed 9 years ago

casertap commented 9 years ago

Everything is fine with the paperclip-ffmpeg version 1.0.1 but when I switch to version 1.2.0 I get this stack:

Command :: PATH=/usr/local/bin/ffmpeg:$PATH file -b --mime '/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150205-9509-104fieg.MOV'
sh: -c: line 0: syntax error near unexpected token `then'
sh: -c: line 0: `PATH=/usr/local/bin/ffmpeg:$PATH if command -v ffprobe 2>/dev/null; then echo "true"; else echo "false"; fi'
Could not log "process_action.action_controller" event. Encoding::UndefinedConversionError: "\xEA" from ASCII-8BIT to UTF-8 [...]

Cocaine::ExitStatusError - Command 'PATH=/usr/local/bin/ffmpeg:$PATH if command -v ffprobe 2>/dev/null; then echo "true"; else echo "false"; fi' returned 2. Expected 0
Here is the command output:

:
  cocaine (0.5.5) lib/cocaine/command_line.rb:92:in `run'
  paperclip-ffmpeg (1.2.0) lib/paperclip_processors/ffmpeg.rb:249:in `detect_command'
  paperclip-ffmpeg (1.2.0) lib/paperclip_processors/ffmpeg.rb:233:in `detect_ffprobe_or_avprobe'
  paperclip-ffmpeg (1.2.0) lib/paperclip_processors/ffmpeg.rb:183:in `identify'
  paperclip-ffmpeg (1.2.0) lib/paperclip_processors/ffmpeg.rb:36:in `initialize'
  paperclip (4.2.1) lib/paperclip/processor.rb:33:in `make'
  paperclip (4.2.1) lib/paperclip/attachment.rb:522:in `block in post_process_style'
  paperclip (4.2.1) lib/paperclip/attachment.rb:521:in `post_process_style'
  paperclip (4.2.1) lib/paperclip/attachment.rb:512:in `block in post_process_styles'
  paperclip (4.2.1) lib/paperclip/attachment.rb:511:in `post_process_styles'
  paperclip (4.2.1) lib/paperclip/attachment.rb:503:in `block (2 levels) in post_process'

If i try to execute the command in my terminal:

$ PATH=/usr/local/bin/ffmpeg:$PATH if command -v ffprobe 2>/dev/null; then echo "true"; else echo "false"; fi
bash: syntax error near unexpected token `then'

I'm on a mac

casertap commented 9 years ago

Forcing cocaine to the version 0.5.3 solved this issue but I do not think this should be the final solution.

jyurek commented 9 years ago

That isn't a valid command in bash. You're saying this works with paperclip-ffmpeg 1.2.0 and cocaine 0.5.3, but not paperclip-ffmpeg 1.2.0 and cocaine 0.5.5? Since this error is a bash error, I don't see why that should be the case. It seems more like this is a problem with paperclip-ffmpeg. What version of bash do you have? I have 4.3.30, and I see the same unexpected token error even when I run this command using cocaine 0.5.3.

casertap commented 9 years ago

My bash version is: GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14) so I have this and the command works:

gem 'paperclip-av-transcoder', "0.6.2"
gem 'cocaine', "0.5.3" 

some logs:

Command :: file -b --mime '/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150206-6043-1ppt3k8.MOV'
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["ffmpeg"], using: Ffmpeg
[AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
[AV] Found ["ffmpeg"], using: Ffmpeg
[AV] Running command: ffmpeg -i "/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150206-6043-13q9yid.MOV" 2>&1
[paperclip] [transcoder] Transocding supported file /var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150206-6043-13q9yid.MOV
[AV] Adding output parameter ["acodec", "aac"]
[AV] Adding output parameter ["strict", "experimental"]
[AV] Adding output parameter [:vcodec, "libx264"]
[AV] Adding output parameter [:acodec, "copy"]
[AV] Running command: ffmpeg -i "/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150206-6043-13q9yid.MOV" -acodec aac -strict experimental -vcodec libx264 -acodec copy -y "/var/folders/43/t8s11k6d145c4wtwfpnbxh640000gn/T/6c84cbd30cf9350a990bad2bcc1bec5f20150206-6043-13q9yid20150206-6043-1bm6gz8.mp4"
ffmpeg version 2.5.2 Copyright (c) 2000-2014 the FFmpeg developers

if I switch to this

gem 'paperclip-av-transcoder', "0.6.2"
gem 'cocaine', "0.5.5"

and bundle update cocaine. I get the error. paperclip-av-transcoder hasn't changed.

jyurek commented 9 years ago

Ah, ok. I see the error now. There was a fix for 0.5.5 that fixed the thread safety bug, but also introduced a problem where it makes commands like this syntactically incorrect: It modified the PATH on the command line. I believe I have a solution for it, though.

casertap commented 9 years ago

Great, I'm happy to not have open an issue for nothing :-) Good luck with that. I will test using the github version of the gem when it will be ok.

jyurek commented 9 years ago

Ok if you want to use that commit (84f557d) the issue should be handled.

jyurek commented 9 years ago

Did this work for you?

ainame commented 9 years ago

I've faced with same problem. And, that commit(84f557d) is good working for me.

jyurek commented 9 years ago

Awesome, thanks for reporting in. I'll cut a new point release tomorrow.

ainame commented 9 years ago

@jyurek How did it get on?

jyurek commented 9 years ago

Completely slipped my mind. But it's up now. Sorry about that. :)