Rails 和回形针 Errno::EACCES 权限被拒绝
我被这个问题困扰好几天了。我在尝试上传图像时不断收到此错误:
Errno::EACCES in MyController#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
当我将上面的这一行复制到命令行并运行它时,它可以工作 - 没有权限被拒绝错误。我应该怎么做才能让 ruby 做到这一点?
我正在运行:
Windows 7
WEBrick 1.3.1
ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
< strong>rails (3.0.7)
Paperclip - 我尝试过版本 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]
以及 在临时文件中将 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"}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我终于找到了一个解决方案,这有点愚蠢:
我重新安装了 ImageMagick,并且没有使用 Program Files 中的默认文件夹,而是选择了文件夹
C:\im
,然后在< code>development.rb 现在,无论有没有样式选项,它都可以完美运行。
感谢所有试图提供帮助的人。
OK, I finally found a solution, it was kinda stupid:
I reinstalled the ImageMagick, and instead of using the default folder in Program Files, I picked folder
C:\im
, than I set thein
development.rb
and now it works perfectly, with and without the styles options.Thanks to everyone who tried to help.