Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Denied on windows server on Fileutils.mv #123

Open
pkazi opened this issue Jun 9, 2020 · 0 comments
Open

Permission Denied on windows server on Fileutils.mv #123

pkazi opened this issue Jun 9, 2020 · 0 comments

Comments

@pkazi
Copy link

pkazi commented Jun 9, 2020

Getting below error on Windows when s3_file downloads the file to temp location and tries to move it to actual remote path.

Error -

>>>> Caused by Errno::EACCES: Permission denied @ rb_file_s_rename - (C:/Windows/Temp/rest-client.20200608-8736-1lxy3l2, C:/chef/cache/cloud_resource-0.1.6.gem)
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:548:in `rename'
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:548:in `block in mv'
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1588:in `block in fu_each_src_dest'
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1604:in `fu_each_src_dest0'
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:1586:in `fu_each_src_dest'
C:/opscode/chef/embedded/lib/ruby/gems/2.5.0/gems/fileutils-1.4.1/lib/fileutils.rb:539:in `mv'
C:/chef/cache/cookbooks/s3_file/providers/default.rb:83:in `block in class_from_file'
(eval):2:in `block in action_create'
C:

It is because of we are passing raw_response = true on RestClient.Request.execute here

And in raw_response, that tempfile is being opened, not closed -
https://github.com/rest-client/rest-client/blob/v1.7.3/lib/restclient/raw_response.rb#L24-L27

As a fix, had to add this in providers/default.rb

      res_file = response.file
      res_file.close unless res_file.closed?
      ::FileUtils.mv(res_file.path, new_resource.path)

s3_file cookbook version - 2.8.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant