Ruby - File.rename() Permission Denied - ruby

On Ruby Im trying to fill a temporary file then rename it but getting permission errors on Windows.
File.rename("tempFile.csv", #data_file)
Error
Permission denied - tempFile.csv (Errno::EACCES)

Try to place
File.chmod(0755, "tempFile.csv") rescue nil
before
File.rename("tempFile.csv", #data_file)

Related

How to resolve permission denied # rb_sysopen

I am writing a simple recipe to create file like:
file '/myfile' do
content 'Welcome to Technical Guftgu'
action :create
end
but on chef-client -zr "recipe[test::recipe1]"
i am getting the following error:
[2022-03-08T10:54:16+00:00] ERROR: Running exception handlers
Running handlers complete
[2022-03-08T10:54:16+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 02 seconds
[2022-03-08T10:54:16+00:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2022-03-08T10:54:16+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2022-03-08T10:54:16+00:00] FATAL: Errno::EACCES: file[/myfile] (test::recipe1 line 7) had an error: Errno::EACCES: Permission denied # rb_sysopen - /myfile
It seems that your app does not have access to the file /myfile.
Try this, to allow access to all: sudo chmod a+rw /myfile
Errno::EACCES Means "Permission Denied"
The Errno class is mapped to your system call errors at runtime. You can find this (confusingly) documented in:
SystemCallError#errno
Errno
In particular:
Errno.constants.include? :EACCES
#=> true
on most *nix sytems Errno::EACCES maps to the libc error code for "permission denied". Specifically:
Macro: int EACCES
"Permission denied." The file permissions do not allow the attempted operation.
That generally means your #create action doesn't have permissions to read, write, or traverse the path to the file you are trying to manage, so you need to change your implementation (which you don't show in your original post) to ensure that your Ruby process has the needed file or filesystem permissions to perform the requested operations.
See Also
Understanding Ruby's strange "Errno" exceptions
errno Lookup
errno.h from The Open Group Base Specifications Issue 7, 2018 edition

cause permission denied while execute golang syscall.MProtect

When I use package syscall like this:
err := syscall.Mprotect(page, syscall.PROT_READ|syscall.PROT_WRITE|syscall.PROT_EXEC)
error occurs as below
permission denied
It seems EACCES error in C. What should I do?

How to fix TextMate error: env: ruby18: Permission denied

I'm using TextMate and every time I tried to use a shortcut cmd + / to comment a line, I get the following message: env: ruby18: Permission denied with an option to either edit the comment of dismiss it. How can I fix that?

Laravel5 cashier downloadInvoice() permission denied error

Unable to download pdf generated with laravel 5 cashier and phantomjs. Throws following error:
ProcessFailedException in Process.php line 233: The command "/PROJECT/vendor/laravel/cashier/src/Laravel/Cashier/bin/linux-x86_64/phantomjs invoice.js /PROJECT/storage/framework/48dc273eaff3a0adaab8aa4f5b1d73df.pdf" failed.
Exit Code: 126(Invoked command cannot execute)
Output:
================
Error Output:
================
sh: 1: /PROJECT/vendor/laravel/cashier/src/Laravel/Cashier/bin/linux-x86_64/phantomjs: Permission denied
I checked storage/framework/ directory pdf has been created with permission 644 and www-data. My storage directory has 777 permission and user say xproject
Can anyone help me to get rid of this error?
I had exactly the same error and after much searching I found this post https://alfrednutile.info/posts/149 by Alfred Nutile
You solve the issue by adding execute permissions to the bin folder recursively:
chmod -R +x vendor/laravel/cashier/src/Laravel/Cashier/bin

Magento site in shows 404 error on frontend, backend, all place

myProject/var/log/system.log shows
2015-04-19T06:39:20+00:00 ERR (3): Warning: file_get_contents(C:\xampp\htdocs\featherfox\app\etc\modules\Oye_License.xml): failed to open stream: Permission denied in C:\xampp\htdocs\myproject\lib\Varien\Simplexml\Config.php on line 496
And i get 404 error: Page not found. on all places.
It appears to be a permissions issue. Normally magento needs the following permissions.
Files should be 644,
Folders should be 755,
Mage executable should be 550 permissions,

Resources