Warning while installing the rails plugin - ruby-on-rails

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.

Related

Should folders like /usr/local/bin be in $PATH? (macOSX)

Do people have directories like /usr/bin or /usr/local/bin be in $PATH since it is usually used when installing new packages through pip and stuff?
I was wondering if it is a good practice to include this to avoid future problems.
Yes, of course, people put /usr/local/bin in PATH. Especially since most macOS users who work from a shell CLI are likely to be using HomeBrew to install things and it's default location is /usr/local/bin. I can't help but wonder if you meant to ask something else.

Error: parent directory is world writable but not sticky

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.

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

Getting Insecure world writable dir when running rails s or rails -v

I've been following the Ruby On Rails Tutorial and tried to get rid of the need for bundle exec.. by following this tutorial video.
However, now when I try to run a command like rails s or rails server. I'm getting this error.
/Users/Keva161/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /Users/Keva161/Documents/Web Design in PATH, mode 040777
/Users/Keva161/.rvm/gems/ruby-1.9.3-p194#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:211: warning: Insecure world writable dir /Users/Keva161/Documents/Web Design in PATH, mode 040777
Does anyone know what this error is and how to fix it?
/Users/Keva161/Documents/Web Design is indeed world-writeable, and is in your PATH; that means anyone with access to your system can place untrusted programs/scripts there and you run the risk of accidentally running them. From the first part of the screencast (I stopped watching when he started talking about Guard), I don't see anything that would have caused this; the closest thing was the chmod command, but I don't see how even a reasonable mistyping could have modified your Web Design directory.
Regardless of that, the fix is to change the permissions of that directory so it's not world-writeable, and optionally take it out of your PATH, depending on whether you actually need it there. A simple chmod o-w "/Users/Keva161/Documents/Web Design" should suffice for the former, but you might want to add -R right after chmod to apply it to all directories under that one. For taking it out of your PATH, I assume you know how to do it in your zsh config file (I don't use zsh so I won't give you a bash answer assuming it will still apply).

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.

Resources