Rails could not find a temporary directory (ArgumentError) - ruby-on-rails

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

Related

How to edit permissions on Heroku application?

My problem in simple terms is that I have an executable that can't be run on Heroku, because it doesn't have the right permissions.
In more details, I have a RoR application on Heroku and I want to use server pdftk. But after installing it I need to chmod the file to be able to use it. And if I run a console on Heroku dashboard, put the chmod command in and try running pdftk it works, but it works just for that temporary dyno and it doesn't work on production server.
I tried creating .profile and putting the command in and that didn't work.
I tried creating Procfile and put release: chmod u+x /app/vendor/pdftk/bin/pdftk and it didn't work.
I tried all different versions of release, web, worker...
I tried creating a .sh file and putting the command in there and then running the file and it doesn't work either.
command for setting permission: chmod u+x /app/vendor/pdftk/bin/pdftk
If you need more info, please tell me.
Any help would be appreciated.
Okay, I figured out what the problem was.
I have a pipeline from gitlab and the permissions just needed to be set through git, so that they were correct when they came to the production enviroment.
I needed to run this code:git update-index --add --chmod=+x pdftk

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.

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.

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