Error: parent directory is world writable but not sticky - ruby-on-rails

I'm running into:
Error: parent directory is world writable but not sticky
While trying to do:
brew install yarn
Error: parent directory is world writable but not sticky
Please report this bug:
https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
/var/lib/jenkins/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.0.0-p648/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir'
Does anybody know how to resolve this?

It is a permission problem, When I am trying to install brew install yarn --without-node, Got this error, on my Mac OSx Sierra
First, find out where is your tmp directory using ls -ld /tmp When I ran this command, got the output in following way,
ls -ld /tmp
lrwxr-xr-x# 1 root wheel 11 Jan 28 2017 /tmp -> private/tmp
which means tmp directory is using private/tmp So try giving the permission by using following command
sudo chmod +t /private/tmp

I had a similar error, but in my case the directory with bad permissions was ~/Library/Caches/Homebrew.
chmod +t ~/Library/Caches/Homebrew
fixed it.

Homebrew/Ruby wants to set sticky bit (+t) permission on /private/tmp folder. Set it explicitly using
sudo chmod +t /private/tmp
will solve the issue. Brew command should work fine after this.

Related

Unable to initialise a git repo because .git: No such file or directory

I am recapping on git in preparation for a project at work and I am falling at the first hurdle when trying to initialise a repo.
I ran the following in GIT BASH (opened as administrator):
cd Users
cd <myuser>
cd Documents
cd git_recap
cd test_project
git init
The last command returns the following error:
C:Users/<myuser>/Documents/git_recap/test_project/.git: No such file or directory
My research tells me that this is a permissions error. I can repeat the exact same steps on my personal computer (not my work one) and it works fine. The problem is that I have no idea which permissions are causing the problem.
I checked the folder permissions for test_project as follows:
cd ..
ls -la
which returns (surmised):
drwxr-xr-x ./
drwxr-xr-x ../
drwxr-xr-x test_project/
I thought: maybe I need to open this folder up for everyone to write to it - fool proof method. I ran:
chmod 777 test_project/
Which returned:
chmod: changing permissions of 'test_project/': Permission denied
I then repeated this process up the folder hierarchy and received the same error message all the way up to the root folder of . I now wanted to see the permissions of all users:
cd ..
ls -la
Which returned:
drwxr-xr-x <myuser>/
To confirm that the issue is with the directory and my permissions within it, I decided to try initialise the repo in the root:
cd <my_user>/
git init
To my surprise, this worked and the repo was succesfully initialised.
Obviously I do not want to initialise my repo here. I want to initialise it in the appropriate test folder.
Any clues what might be wrong and what I might try to correct this?
EDIT
I get identical results when doing the same set of steps from command line (also ran as administrator)
I have stumbled across what I believe is the solution: Windows Security Controlled Folder Access.
This feature is enabled by default on my work laptop and prevents tampering with certain User folders to provide better security in the event of a breach - in particular ransomware.
Unfortunately for me, IT have the power to turn it off - not me.

Permissions issue when installing yarn in a docker image

My dev team is currently setting up the environment for the updates on a proyect we've developing. I'm going straight to the point.
In our DockerFile we are installing yarn with RUN npm install -g yarn
But when executing an .sh file that empties cache files, we got the error:
yarn error “EACCESS: permission denied, scandir '/root/.config/yarn/link'”
I've looking up for possible fixes, and we only found a workaround which is to give full permissions to that directory:
RUN chmode -R 777 '/root/
And we know this is highly not recommended.
Does anyone know a better answer? I've seen tons of issues like this one with yarn and docker.
Yarn version is 1.9.4
Edit1:
The problem is that yarn writes or read these file with the user that executes this action, so the solution would be to grant permission to all user. Maybe in a more retrictive way?
EDIT:
After lots of failures we decided to just use chmode -R 777 ~/.config && chmode -R 777 ~/.cache Those files were not created until we ran a yarn install, what due to how we developed the sistem, was triggered everytime an user entered the sistem. So the workaround was to just give 777 permissions to every user in order to let them write onto these files.
Anyway, if anything better comes up, I'll post the answer here.
Btw the system got deprecated
Try this In dockerfile
USER root
RUN npm install -g yarn
USER [user name]
RUN chown -R [user name] ~/.config && chown -R [user name] ~/.cache
https://docs.npmjs.com/getting-started/fixing-npm-permissions
try
sudo npm install yarn && yarn install
We ended up setting 777 permissions, but that system got deprecated.

Rails could not find a temporary directory (ArgumentError)

I'm uploading my Rails proyect to a Ubuntu Server running 12.04LTS and I can't seem to fix this issue! Whether I do a bundle install or try to use the whenever gem I get that error! I've read a lot but still I'm unable to fix it
/lib/ruby/2.0.0/tmpdir.rb:34:in `tmpdir': could not find a temporary directory (ArgumentError)
And my ls -la of the / folder
Any ideas?
P.s I tried chmod -R 777 on /tmp with no luck
The short answer is to just run this like #hagello suggests.
chmod +t /tmp
Then it should start working again.
edit: As suggested in the comments just run
chmod +t /tmp
========
Old answer:
Your Ubuntu installation probably doesn't have TMPDIR set. You should set that variable in your startup.
This link has more information on environment variables in Ubuntu: https://help.ubuntu.com/community/EnvironmentVariables

Permission denied in tmp

I just deployed a Rails 3 app with Ruby 1.9.2. I have been getting several errors.
application.css wasn't compiled. so I set pre compilation in production.rb to false;
Then I got: cannot generate tempfile, so I did rake tmp:clear;
And now I get ActionView::Template::Error (Permission denied - /srv/www/appname/tmp/cache/assets): and I haven't been able to fix this one.
Please help.
If the user:group running your web server is http:http and it's running on *nix, do this:
sudo chown -R http:http /srv/www/appname/
Also, silly question, but does /tmp/cache/assets exist?
And, if so, as #leonel points out, you may also need to change the permissions:
chmod 777 /srv/www/appname/tmp/cache
Be careful setting 777 permissions on anything. Only do this to verify a permissions issue, then reset to the most minimal permissions necessary.
Most likely you're running your app under apache passenger.
You have to change the owner of config/environment.rb to somebody who has permissions to your app's folder.
chown -R www-data:www-data /path/to/app
Make the tmp folder of your project writable:
chown -R group:user /path/to/rails/app/tmp
chmod -R 777 /path/to/rails/app/tmp
In your console, run rake tmp:cache:clear
Restart your application.
You probably didn't create your Rails application with the user running the server now. Can you paste the output of ls -alh /srv/www/appname/tmp/cache/assets and tell us the user running the webserver ?
Now for those of us that are using windows
- If you are an administrator and see this error
ActionView::Template::Error (Permission denied # utime_failed) C:/User/..../tmp/cache/assets/sprochets/v3.0/E5/E5PZx-mq8.cache
Then it is Permission and Ownership setting issue on Windows.
You can go to the tmp folder on your application and give yourself(User) permission to **Read, Write and Execute ** on the folder.
Click [here][1] to view how to give permissions.
Quick Fix. Open your terminal and run the following command as an administrator
takeown /f <location of your app tmp folder> /r /d y
Then Restart your server.
I encountered this error recently. Apache was not able to write to tmp directory
cannot generate tempfile
/tmp/RackRewindableInput2xxxxxxxxxxxxxxxxx'
/app-lib/lib/ruby/1.8/tempfile.rb:52:ininitialize'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:in new'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:73:inmake_rewindable'
app-dir/vendor/gems/rack-1.0.1/lib/rack/rewindable_input.rb:26:in read'
app-dir/vendor/gems/rack-1.0.1/lib/rack/request.rb:134:inPOST'
I checked permission of tmp directory and it had permission to all groups to write to it.
I changed owner of tmp directory and it didn't resolve the error either.
The culprit was tmp directory was filled with too many large files, and looks like somehow apache didn't had enough space to write this new file.
Cleared all temp and old files. It sorted out the issue.
We need to grant permissions to access the required directory for the system root user
sudo chmod 777 -R your_project_directory_to_be_access
In your case you can use:
sudo chmod 777 -R /srv/www/appname/tmp/
For security reasons, just keep in your mind:
chmod 777 gives everybody read, write and execute rights which for most problems is definitively too much.
I think a better solution without giving everyone manage rights to tmp folder is like that:
sudo rake tmp:cache:clear
This will clear the temp folder and when you run rails server again it won't give error.
In my localhost it gave this error, and the command chmod 777 C:/Sites/project_name/tmp/cache/ solved my problem.
Most probably you gave permission to your app's main folder read and execute mode. However, in order to generate new files from your app, you also need to give write permission for required folder. For example: yUML uses tmp folder for generating files. I gave tmp folder write permission:
chmod -R 777 /usr/share/nginx/html/yuml_product/tmp
solved my problem.

Warning while installing the rails plugin

I am getting the following warning while installing any plugin in my rails application.
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/agnostics.rb:7: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Can someone please tell me how to solve this problem?
Thanks
Ruby (on all Unixes, including Cygwin) warns if you try to run an external program and your $PATH contains a world-writable directory. It doesn't just check the directories on $PATH: it checks each of their parents, too, because if /usr/local (say) is world-writeable, /usr/local/bin is subverted as easily as if it were writeable itself.
A work-around could be to remove "other" write permission from the relevant directories.
For instance:
chmod o-w /usr/local/bin
chmod o-w /usr/local
chmod o-w /cygdrive/c
This is due to the fact that /usr/local/bin is writable by your application when maybe it shouldn't. You can fix this by changing the permissions on this directory.

Resources