开发者

Rails and Paperclip Errno::EACCES Permission denied

开发者 https://www.devze.com 2023-03-07 19:24 出处:网络
I\'m stuck with this for days. I keep getting this error trying to upload image: Errno::EACCES in MyController#create

I'm stuck with this for days. I keep getting this error trying to upload image:

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

when I copy this line above to the command line and run it, it works - no permission denied error. What should I do to allow ruby do it?

I'm running on:

Windows 7

WEBrick 1.3.1

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

rails (3.0.7)

Paperclip - I've tried versions 2.3.11, 2.3.4, and 2.3.6, and 2.3.10 but I still keep getting the same error.

I've googled a lot for a solution and aplied the tempfile fsync fix found on [http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu-hello-paperclip][1]

and also the file.mv replacement with copy and delete, in tempfile, that looked like the solution, but that doesn't help. These fixes besides seems to be in the newer versions of paperclip by default.

Of course I restarted webrick allways I made any changes.

The console info by server, when this problem rises:

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'

Any ideas how to fix this?

Thanks a lot

EDIT:

the request parameters are:

{"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"}


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 the

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

in development.rb and now it works perfectly, with and without the styles options.

Thanks to everyone who tried to help.

0

精彩评论

暂无评论...
验证码 换一张
取 消