Rails和Paperclip Errno :: EACCES权限被拒绝

时间:2011-05-22 10:55:58

标签: ruby-on-rails ruby paperclip

我坚持了好几天。尝试上传图片时出现此错误:

Errno :: MyController中的EACCES #create

Permission denied - c:\"Program Files\ImageMagick-6.6.9-Q16"/convert "C:/Users/USER/AppData/Local/Temp/stream20110522-5332-1e34ydw.jpg[0]" -resize "848x608!" "C:/Users/USER/AppData/Local/Temp/stream20110522-5332-1e34ydw20110522-5332-z5iv1g" 2>NUL

当我将上面的这一行复制到命令行并运行它时,它可以工作 - 没有权限被拒绝错误。我应该怎么做才能让红宝石做到这一点?

我正在继续:

Windows 7

WEBrick 1.3.1

ruby​​ 1.9.2p180 (2011-02-18)[i386-mingw32]

rails(3.0.7)

回形针 - 我尝试过版本 2.3.11,2.3.4和2.3.6以及2.3.10 ,但我仍然遇到同样的错误。

我已经搜索了很多解决方案,并在[http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip][1]

上找到了临时文件fsync修复程序

还有 file.mv替换为临时文件中的复制和删除,看起来像解决方案,但这没有帮助。除了默认情况下,这些修补程序似乎也出现在较新版本的回形针中。

当然我重新启动了webrick总是我做了任何改动。

服务器的控制台信息,当此问题出现时:

Started POST "/admin/front_campaigns" for 127.0.0.1 at 2011-05-22 12:35:10 +0200
  Processing by FrontCampaignsController#create as HTML
  Parameters: {"utf8"=>"Ôťô", 

"authenticity_token"=>"DwX4TRaU1wGOleyxhjzpcmmg2m9pbtzLOj1WOa48cXc=", "front_campaign"=>
{"picture"=>#<ActionDispatch::Http::UploadedFile:0x41bd508 @original_filename="home1.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"front_campaign
[picture]\"; filename=\"home1.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:C:/Users/USER/AppData/Local/Temp/RackMultipart20110522-5292-2recc
l>>, "name"=>"", "description"=>"", "web"=>"", "position_x"=>"1", "position_y"=>"1"}, "commit"=>"Create Front campaign"}
[paperclip] c:\"Program Files\ImageMagick-6.6.9-Q16"/identify -format %wx%h "C:/Users/USER/AppData/Local/Temp/stream20110522-5292-ks7a6r.jpg[0]" 2>NUL
[paperclip] c:\"Program Files\ImageMagick-6.6.9-Q16"/convert "C:/Users/USER/AppData/Local/Temp/stream20110522-5292-ks7a6r.jpg[0]" -resize "848x608!" "C:
/Users/USER/AppData/Local/Temp/stream20110522-5292-ks7a6r20110522-5292-17svo7l" 2>NUL
Completed   in 360ms

Errno::EACCES (Permission denied - c:\"Program Files\ImageMagick-6.6.9-Q16"/convert "C:/Users/USER/AppData/Local/Temp/stream20110522-5292-ks7a6r.jpg[0]"
 -resize "848x608!" "C:/Users/USER/AppData/Local/Temp/stream20110522-5292-ks7a6r20110522-5292-17svo7l" 2>NUL):
  app/controllers/front_campaigns_controller.rb:44:in `new'
  app/controllers/front_campaigns_controller.rb:44:in `create'

/sorry for the formating, I was unable to get a nicer copy of windows commandline/

full trace:

activesupport (3.0.7) lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

activesupport (3.0.7) lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

paperclip (2.3.10) lib/paperclip/command_line.rb:27:in `run'

paperclip (2.3.10) lib/paperclip.rb:104:in `run'

paperclip (2.3.10) lib/paperclip/thumbnail.rb:61:in `make'

paperclip (2.3.10) lib/paperclip/processor.rb:33:in `make'

paperclip (2.3.10) lib/paperclip/attachment.rb:344:in `block (2 levels) in post_process_styles'

paperclip (2.3.10) lib/paperclip/attachment.rb:343:in `each'

paperclip (2.3.10) lib/paperclip/attachment.rb:343:in `inject'

paperclip (2.3.10) lib/paperclip/attachment.rb:343:in `block in post_process_styles'

paperclip (2.3.10) lib/paperclip/attachment.rb:339:in `each'

paperclip (2.3.10) lib/paperclip/attachment.rb:339:in `post_process_styles'

paperclip (2.3.10) lib/paperclip/attachment.rb:333:in `block (2 levels) in post_process'

activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_picture_post_process_callbacks'

activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'

paperclip (2.3.10) lib/paperclip/callback_compatability.rb:54:in `run_paperclip_callbacks'

paperclip (2.3.10) lib/paperclip/attachment.rb:332:in `block in post_process'

activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_post_process_callbacks'

activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'

paperclip (2.3.10) lib/paperclip/callback_compatability.rb:54:in `run_paperclip_callbacks'

paperclip (2.3.10) lib/paperclip/attachment.rb:331:in `post_process'

paperclip (2.3.10) lib/paperclip/attachment.rb:110:in `assign'

paperclip (2.3.10) lib/paperclip.rb:252:in `block in has_attached_file'

activerecord (3.0.7) lib/active_record/base.rb:1559:in `block in attributes='

activerecord (3.0.7) lib/active_record/base.rb:1555:in `each'

activerecord (3.0.7) lib/active_record/base.rb:1555:in `attributes='

activerecord (3.0.7) lib/active_record/base.rb:1407:in `initialize'

app/controllers/front_campaigns_controller.rb:44:in `new'

app/controllers/front_campaigns_controller.rb:44:in `create'

actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:5:in `send_action'

actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'

actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'

actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'

activesupport (3.0.7) lib/active_support/callbacks.rb:446:in `_run__41168123__process_action__129617020__callbacks'

activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'

activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'

actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'

actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in 
process_action'

activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'

activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'

activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'

actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'

actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'

actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'

actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'

actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'

actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'

actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'

actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'

actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispa
tch'

actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'

rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'

rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'

rack-mount (0.6.14) lib/rack/mount/code_generation.rb:75:in `optimized_each'

rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'

rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'

actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:493:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'

rack (1.2.2) lib/rack/methodoverride.rb:24:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'

activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'

activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in 
`cache'

activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'

activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'

activerecord (3.0.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'

activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'

actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'

rack (1.2.2) lib/rack/sendfile.rb:107:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'

railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'

rack (1.2.2) lib/rack/runtime.rb:17:in `call'

activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'

rack (1.2.2) lib/rack/lock.rb:11:in `block in call'

<internal:prelude>:10:in `synchronize'

rack (1.2.2) lib/rack/lock.rb:11:in `call'

actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'

railties (3.0.7) lib/rails/application.rb:168:in `call'

railties (3.0.7) lib/rails/application.rb:77:in `method_missing'

railties (3.0.7) lib/rails/rack/log_tailer.rb:14:in `call'

rack (1.2.2) lib/rack/content_length.rb:13:in `call'

rack (1.2.2) lib/rack/handler/webrick.rb:52:in `service'

C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'

C:/Ruby192/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'

C:/Ruby192/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

任何想法如何解决这个问题?

非常感谢

编辑:

请求参数是:

{"utf8"=>"✓",

 "authenticity_token"=>"DwX4TRaU1wGOleyxhjzpcmmg2m9pbtzLOj1WOa48cXc=",

 "front_campaign"=>{"picture"=>#<ActionDispatch::Http::UploadedFile:0x3fe1b10 
@original_filename="home1.jpg",

 @content_type="image/jpeg",

 @headers="Content-Disposition: form-data; name=\"front_campaign[picture]\"; filename=\"home1.jpg\"\r\nContent-Type: image/jpeg\r\n",

 @tempfile = File:C:/Users/USER/AppData/Local/Temp/RackMultipart20110522-4824-1tyjwrv>, // this tempfile is created

 "name"=>""},

 "commit"=>"Create Front campaign"}

1 个答案:

答案 0 :(得分:2)

好吧,我终于找到了一个解决方案,它有点愚蠢:

我重新安装了ImageMagick,而不是使用Program Files中的默认文件夹,我选择了文件夹C:\im,而不是我设置

Paperclip.options[:command_path] = "C:\\im" 

development.rb中,现在它完美无缺,有或没有样式选项。

感谢所有试图提供帮助的人。