Permission denied in homebrew - homebrew

I'm trying to utilize the msmtp package downloaded from homebrew.
I also setup my .mailrc file pointing at the msmtp bin as specified in the instructions
set sendmail="/opt/homebrew/Cellar/msmtp/1.8.22/bin"
Then I receive the following error:
mail: /opt/homebrew/Cellar/msmtp/1.8.22/bin: Permission denied
I found a permissions solution here: How to fix homebrew permissions?
where I changed the permission for brew paths but this did not work for me
sudo chown -R $(whoami) $(brew --prefix)/*
Is there any other way I should be changing permissions?

Related

How do I remove Permission denied # rb_sysopen - Gem install error?

I am trying to install create a new app in Ruby on Rails and I cannot get passed this error:
$ gem install pg
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/pg-0.21.0/.gemtest
Its a permissions issue. You could fix it with this:
sudo chown -R $(whoami) /Library/Ruby/Gems/*
or possibly in your case
sudo chown -R $(whoami) /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/*
What does this do:
This is telling the system to change the files to change the ownership to the current user. Something must have gotten messed up when something got installed. Usually this is because there are multiple accounts or users are using sudo to install when they should not always have to.
It's likely there's a permissions problem somewhere along the .rbenv path. You might try turning on write privileges for your user with:
$ chmod -R +w ~/.rbenv
That will recursively (-R) change the file mode (chmod) to write permission (+w) for all files and directories under your user's .rbenv path. There's no particular reason for not having files set to write.
For Mac M1 systems try,
Allowing full disk access to terminal.
Apple->systemPreferences->Security&Privacy->privacy(Tab)->'+' button, check in Terminal application.
Then Restart terminal
2.Try using,
sudo chflags noschg
Delete the pod folder, reinstall it again. If it doesn't work use this command:
sudo pod install --allow-root
It really doesn't matter on mac how you configure your eyaml create the dir and config manually, add some public key location to it, and its works just fine after adding full disk access to the terminal as Kewin suggested ^ ^. Thumbs up.
No need to change permission, just export GEM_HOME:
export GEM_HOME="$HOME/.gem"
please run:
sudo gem install pg

rbenv Permission denied with Assetic on Ubuntu

I struggled for hours trying to have Assetic with Sass and Compass working on my production server.
The error is:
sh: 1: /root/.rbenv/shims/ruby: Permission denied
This is because my rbenv instalation is under the /root directory so Assetic doesn't have the permision to use it.
I've checked similar issues:
"Rbenv permission denied issue"
"rbenv: Permission Denied"
"Should rbenv be installed system-wide, or at a user level?"
but they didn't help.
I'm using Apache so I guess the default user is "www-data".
As explained in one of the above questions, I tried to grant www-data the permission in /root but either this didn't work or I did it wrong.
sudo chown -R www-data ~/.rbenv
This is the complete error:
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
'/root/.rbenv/shims/ruby' '/usr/local/bin/compass' 'compile' '/var/www/myapp/app/cache/dev' '--boring' '--images-dir' '/var/www/myapp/app/../web/uploads/img' '--config' '/var/www/myapp/app/cache/dev/assetic_compassu3IAzJ' '--sass-dir' '' '--css-dir' '' '/var/www/formation-hero/app/cache/dev/assetic_compassPbwM3H.scss'
Error Output:
sh: 1: /root/.rbenv/shims/ruby: Permission denied
I'm using Apache on Ubuntu 14.04
# which ruby
/root/.rbenv/shims/ruby
# which compass
/usr/local/bin/compass
# which rbenv
/root/.rbenv/bin/rbenv
# rbenv -v
rbenv 1.0.0-14-gc388331
Symfony 2.7 is installed under /var/www/myapp/
What should I do to either give right to Apache to use the /root repository or, maybe better, how do I install rbenv for my Symfony2 project?
Everything is working fine on my localhost with OS X.
I do not have experience with the said components but assuming that the user who is executing the file is www-data it might be an issue with the permissions of the /root/.rbend/shims/ruby file.
Run the command sudo chmod o+x /root/.rbenv/shims/ruby wich will give execute permissions to the owner of the file, presumably www-data since you ran the chown command.
If it still doesn't work run the command ls -l /root/.rbenv/shims/ruby, the 4th character of the first column should be x, indicating the owner has execution permissions.
For more info on linux file permissions check "Understanding and Using File Permissions".

How to grant a folder with write permissions for installing gems in Ruby

the biggest problem I have with installing anything on my computer related to Ruby and Rails, is not having 'write' permissions to a specific folder.
For example: "You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory"
Instead of always using Sudo command, which sometimes doesn't solve the problem, how can I give myself 'write' permissions?
sudo chmod 777 directory_name
It grants all permissions to the user.

I can't install gems with rvm

I'm new to ruby version manager and when i tried to install rails after installing it, I get this error . I tried to search other SO questions as well but didn't want to re-install ruby version manager. Even though when I try sudo for installation, it doesn't work.
The error I get is as follows:"ERROR: While executing gem ... (Errno::EACCES)Permission denied # dir_s_mkdir - /home/sunil/.gem/specs"
I would do this:
ls -ld /home/sunil/.gem/specs to check that folder permissions.
whoami to compare current user with /home/sunil/.gem/specs permissions
Maybe chown -R sunil:sunil ~/.gem to change owner in case .gem directory is not owned by sunil.
Maybe chmod -R u+rwX,go+rX,go-w ~/.gem to change permissions.

Permission Denied in rvm update and rvm remove

There is rvm 1.19.6 installed on ubuntu 12.04 with ruby 2.0.0. Just receive permission denied when doing rvm get stable. Here is the error:
$rvm get stable
######################################################################## 100.0%
bash: line 535: /home/ubuntu/.rvm/RELEASE: Permission denied
Could not update RVM, get some help at #rvm IRC channel at freenode servers.
When we are trying to installing readline on the server, the rvm remove 2.0.0 creates the permission deny error:
$rvm remove 2.0.0
tee: /home/ubuntu/.rvm/log/ruby-2.0.0-p0/1367720906_remove.src.log: Permission denied
tee: /home/ubuntu/.rvm/log/ruby-2.0.0-p0/1367720906_remove.src.log: Permission denied
Removing /home/ubuntu/.rvm/src/ruby-2.0.0-p0...........
.........
Error running '__rvm_rm_rf /home/ubuntu/.rvm/rubies/ruby-2.0.0-p0',
please read /home/ubuntu/.rvm/log/ruby-2.0.0-p0/1367720907_remove.rubies.log
rm: cannot remove `/home/ubuntu/.rvm/bin/ruby-2.0.0-p0': Permission denied
Removing ruby-2.0.0-p0 aliases...
Removing ruby-2.0.0-p0 wrappers...
rm: cannot remove `/home/ubuntu/.rvm/wrappers/ruby-2.0.0-p0/ruby': Permission denied
rm: cannot remove `/home/ubuntu/.rvm/wrappers/ruby-2.0.0-p0/rake': Permission denied
rm: cannot remove `/home/ubuntu/.rvm/wrappers/ruby-2.0.0-p0/erb': Permission denied
rm: cannot remove `/home/ubuntu/.rvm/wrappers/ruby-2.0.0-p0/gem': Permission denied
We tried to delete ~/.gem/ and assign the right to ~/.gem/specs following this post, it did not work. What's wrong with the rvm? Thanks for help.
pulling from comments.
rvm was installed as root, and needs to be owned by the ubuntu user (or you need to run all commands as root)
sudo chown -R ubuntu .rvm will fix the permissions errors
as for the ruby 2.0.0#global it doesn't need to be removed. if you look at the rvm documents that is used as a place to install gems that should be across all gemsets for that particular version of ruby for instance I have bond, hirb, wirb, awesomeprint all in my global as they are referenced in my .irbrc. So as I create per project gemsets I always have them available to me (things like bundler are also handy there)

Resources