Permission denied installing libxml2 - homebrew

So I'm working on updating my rails environment to support 4.0 and ruby 2.0. So far I've had some trouble installing libxslt. When run in the terminal I get:
$ brew install libxml2
Error: Permission denied - /usr/local/lib/python2.7/site-packages/sitecustomize.py
I'm running this as a root user so the permission denied message is quite puzzling. Any help is appreciated.

You shouldn't install things to /usr/local as root or via sudo. From the FAQ
Why does Homebrew say sudo is bad?
Homebrew is designed to work without using sudo. You can decide to use it but we strongly recommend not to do so. ...
If you run the following, you can force the ownership of /usr/local in it's entirety to your logged in user
sudo chown -R `whoami` /usr/local
Source
You should no longer get Permission Denied issues once that's been applied.

Related

Upgrade rails version permission denied rvm folder /bin/rails

I try to install rails 3.2.20 with ruby2.2.0.
So with rvm I make
rvm install 2.2.0
After I make
gem install rails -v 3.2.20
After rvm use default ruby-2.2.2
But when I try rails -v, I have the error
-bash: /home/xxx/.rvm/gems/ruby-2.2.0/bin/rails: Permission denied
Why? I try also chmod -R 777 on .rvm but nothing change
If I try
which ruby I have
/usr/local/rvm/rubies/ruby-2.2.0/bin/ruby
If I try whch rails I have nothing
check if you are logged in as the correct user
check if the permissions of the user’s home directory are correct, e.g. /home/xxx/
remove the ruby under /usr/local/bin
reinstall rvm if all fails

Is using sudo to set up Ruby on Rails considered a bad practice?

How can I avoid using sudo?
I am setting up ruby on rails on my mac ox yosemite, and along the way, I inevitably end up using 'sudo' for some of my commands. This helps me overcome the error below:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
For more context, I am following this tutorial and in the section on Final Steps, I was unable to execute
rake db:create
because I needed to install pg and my user account isn't allowed to install to the system Rubygems.
I managed to overcome this problem from following the steps here (taken from this post)
Install Xcode command line tools (Apple Developer site)
brew uninstall postgresql
brew install postgresql
ARCHFLAGS="-arch x86_64" gem install pg
EXCEPT that the last step for me was
sudo ARCHFLAGS="-arch x86_64" gem install pg
Questions:
1) By using sudo - what is the implication on my computer?
2) How can I improve my set up to avoid having to use sudo?
Generally, you should not run commands using sudo unless you absolutely have to. I think the bigger issue here is that you are using your system Ruby which is preventing you from running some of these commands because the gem executable is owned by the root user.
I would use the Ruby Version Manager so you can have a dedicated Ruby/RubyGems executable for your specific user.
Installing RVM https://rvm.io/
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable
Keep in mind that you are more then likely still going to require escalated privileges to install things like Postgresql on your machine.
Remember, if you are running your web server as the root user, you are putting the system at a more vulnerable state. Let's say you built an app that has the ability to delete files on the server, well what if it accidentally deleted the root file system? You know, bad stuff like that.

Permission denied , installing rails

I am trying to install rails , in order to install cocoapods but I am having some trouble with permissions.
I tried $ $sudo chown -R username /usr/ but operation is now allowed.
Username-MacBook-Pro:~ username$ $sudo gem install rails
Building native extensions. This could take a while...
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # dir_s_mkdir - /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14
Username-MacBook-Pro:~ username$
You should not install rails with the sudo command for two reasons:
I made this mistake in the past and then I had issues when installing and using other gems because of inconsistencies with permissions. It might very likely cause you the same trouble.
The concern of whether or not to install rails with the sudo command is addressed and well explained in a different post: 'sudo gem install' or 'gem install' and gem locations
The reason why installing gems with sudo is worse than just gem install is because it installs the gems for ALL USERS as root. This might be fine if you're the only person using the machine, but if you're not it can cause weirdness.
I recommend that you install rvm first and then rails. Here is a great tutorial that walks you through the process: http://railsapps.github.io/installrubyonrails-mac.html

rbenv rehash gives me Permission denied # rb_sysopen

After upgrading to Rails 4.0.4 and Ruby 2.1.1, i have permission problems with rbenv rehash. I tried bundler install to 1.5.3. Ok. But still no. bashrc (Ubuntu 13.04) is fine, that is, as before. ruby -v shows the proper versions of global and local Ruby, as does rails -v. Only 'rehash' seems to be the problem.
.rbenv/plugins/bundler/etc/rbenv.d/bundler/rehash.rb:187:in `initialize': Permission denied # rb_sysopen
Try running the server as a root.
sudo -s
rails s
Change the owner of the dependency files:
sudo chown -R USERNAME /.rvm/
And then change owner of the project file:
sudo chown -R USERNAME /var/www/PROJECTFILE

Error: Cowardly refusing to `sudo brew install` for installing glue 0.3 for Mac OSX Mountain Lion

I'm trying to install glue 0.3 for OXS Mountain Lion and ran into this error after installing homebrew (Error: Cowardly refusing to sudo brew install You can use brew with sudo, but only if the brew executable is owned by root. However, this is both not recommended and completely unsupported so do so at your own risk.) I got this error after the first step for installing glue 0.3 ($ sudo brew install jpeg). No idea how to fix this...please help!
sudo chown root /usr/local/bin/brew
sudo chown -R $USER /usr/local
Use the above command instead of changing the owner of brew to root.
This is the suggested method by the Owner of homebrew in https://github.com/Homebrew/homebrew/issues/9953
Answered by the developers here:
https://github.com/Homebrew/homebrew/issues/9953
I solved it by NOT using sudo, and changing the permissions on whatever file it says cannot be accessed without sudo.
For example, I could not access /usr/local/Cellar, so I entered the following (as specified here: https://github.com/Homebrew/homebrew/issues/3930)
sudo chmod g+w /usr/local/Cellar
sudo chgrp staff /usr/local/Cellar
For High Sierra macOS 10.13.3 or newer.
None of the solutions given here worked for me on this version. The only (and the best) fix is to uninstall brew and install it again with the following terminal commands. Note you will lose your current kegs, so you should get a list of the installed kegs, for reinstalling them after reinstalling brew as shown below under step 1. Actually, this was a good opportunity for me to get rid of those kegs that I am no longer using:
List your current kegs for reinstalling, those you wan't to keep:
brew list
Uninstall brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Reinstall brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Optionally to prevent your usage being sent to Google Analytics (Update: Fortunately, now this has been stopped, so you may skip this step):
brew analytics off
Finally reinstall your previous kegs from step 1 (or those you still want to use). Replace the text with the square brackets with the list, (i.e. brew install sqlite heroku ):
brew install [list of kegs from step 1]
I have updated my macos to sierra and npm stopped working. Below are the steps followed to fix them.
Uninstall Node and install it from brew and follow the below steps
sudo chmod g+w /usr/local/Cellar
sudo chgrp staff /usr/local/Cellar
sudo chown root /usr/local/bin/brew
sudo brew postinstall node
This was helpful for me
http://digitizor.com/fix-cowardly-refusing-sudo-error-brew/
As quoted in the text, you essentially have to change the user and group of brew to root and wheel respectively.

Resources