permissions for the /Library/Ruby/Gems/1.8 directory - octopress

I want to download and set octopress, and I follow the hint and type:
$cd octopress
$gem install bundler
then it shows that:
"ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/1.8 directory.
What does it mean? I don't know how to write permissions for it. What should I do?

Your question lack some basic information, I would say ;) For this kind of problem you should include at least your OS (I guess you are on mac os because of the /Library directory)
What the error says is that, as a normal user, you cannot write in the /Library directory, which is a system directory (and as such require administrator privilege).
From what I read, there is no root account on mac os by default, but maybe you can use sudo to issue a command with temporary privilege: try
sudo gem install bundler
and see if it works (it should prompt you from your password).
Otherwise, you can certainly install the program locally (in your $HOME), but as I never used mac os I can't really help you here. If the above does not work, I suggest you rephrase your question as "using gem on mac os", or something similar.

Related

"You don't have [PATH ]in your PATH, gem executables will not run." while using "gem install --user-install bundler"

I was trying to install jekyll in my Mac and got the warning as following:
WARNING: You don't have /Users/Carrot/.gem/ruby/2.3.0/bin in
your PATH, gem executables will not run.
I checked through gem list and it shows it is installed; and I can find the jekyll through the path "/Users/Carrot/.gem/ruby/2.3.0/bin". I read a post which seems like my situation. I would like to know if it's a must to go through sudo? I now prefer to uninstall everything (since it also installed sass and bunch of things at the same time) and go through homebrew. How can I do the uninstallation?
Many thanks!
For those who have problems with #lamech-desai answer, (actually, when they do Desai's commands, it apparently works temporarily for them).
So you can easily do these:
open ~/.bshrc if you would like to use bash or ~/.zshrc if your are using zsh or etc...
$ sudo nano .bashrc ## bash users
$ sudo nano .zshrc ## zsh users
then copy and past these two lines of code at the end of the .*rc file:
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
then simply press ctrl+s and ctrl+x. This will save the changes to .bashrc but you won't see them immediately - directly on your next shell login with your current user. One way to see the changes immediately is to switch user to root with su root and then switch back to your previous user with su <username> - and voila, your .bashrc will be reloaded. You can also check this with echo $PATH.
Thanks to #lamech-desai for great answer
If you are using arch linux just use the commands below in your terminal
[user~]$ export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
[user~]$ export PATH="$PATH:$GEM_HOME/bin"
[user~]$ gem list
[user~]$ gem update
You need to add the directory to your PATH environment variable
https://askubuntu.com/questions/406643/warning-you-dont-have-a-directory-in-your-path-gem-executables-will-not-run
If you are on a Mac like me, you need to add the PATH to the PATH environmental variable. You can do it with export command:
export PATH="/Users/Carrot/.gem/ruby/2.3.0/bin:$PATH"
If you wanna know more about this process, here is a blog post about this: Adding a Path to the Linux PATH Variable
Probably a bit odd to answer my own question but I did finally fix it somehow like a blind fly. I hope to write down the experience maybe who else is totally like me as a absolute beginner with everything wouldn't get struggling overnight.
Stage 1: from gem to homebrew (failed)
At the beginning, I did remove items that install in gem item-by-item, then I install brew-gem to do it. At some stage, it work for jekyll but not my theme. It kept popping out I didn't install a package that the theme needs even I installed it manually. So in the end, I remove everything related to jekyll from homebrew.
Stage 2: back to gem (very long path but finally made it)
I later found a page tell step-by-step to install jekyll. I am using OSX 10.13 (High Sierra) that cause me the permission problem. So I just granted access with this line:
sudo chown -R $(whoami) /usr/local/*
The * is a must or it won't work. I did the same to the ruby part
sudo chown -R $(whoami) /Library/Ruby/Gems/2.3.0/*
After that I install jekyll and bundler carefully following the instruction. And install the packages that the theme needs manually through gem install, which you can find at the Gemfile. I got the problem of jekyll-sitemap similar as this, I followed the method to install pygment.rb through gem install pygments.rb. And now my site is locally work.

Fixing brew doctor warnings/errors

I have recently installed Homebrew and RVM. However, when I tried to install a new version of Ruby into RVM:...
rvm install 2.2
I got the following error:
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.9/x86_64/ruby-2.2.0.tar.bz2
Checking requirements for osx.
ERROR: '/usr/local/bin' is not writable - it is required for Homebrew, try 'brew doctor' to fix it!
Requirements installation failed with status: 1.
So I ran the doctor command to view errors and saw:
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: /usr/local/bin isn't writable.
This can happen if you "sudo make install" software that isn't managed by
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.
I found the same issue with various other directories:
/Library/Caches/Homebrew
/usr/local/Cellar
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/lib/pkgconfig
/usr/local/opt
/usr/local/share
/usr/local/share/man
/usr/local
When I installed RVM, I did a single user install into a non admin account. This non admin account I will be using as my development account. Is this ok, or should I be developing using an admin account? I am running into all sorts of permissions type issues; eg trying to install a gem, because of write permissions failures and am now questioning what is the proper way to develop code, without being an admin, or should I be an admin?
I was going to start using chown to fix these errors ie
chown $USER -R /usr/local/bin
but, this worries me. Do I want to be changing the owner of all these system directories to my non admin account? Just want some re-assurance really before I go ahead, it just feels, wrong. (PS; is that the correct use of chown?)
I've seen other articles that suggest using sudo, but I've also seen artciles that say you shouldn't use sudo. Err-ing on the side of caution, I would rather not use sudo.
Thanks.
Most of these questions are pretty well covered by the Homebrew FAQ.
Do I want to be changing the owner of all these system directories to my non admin account?
System libraries are not installed to /usr/local. Apple doesn't include that directory on a clean install. Most likely some other installer put things there as root or another user.
I've seen other articles that suggest using sudo, but I've also seen artciles that say you shouldn't use sudo.
Homebrew should not be used with sudo, but it does assume the user is an admin and has rights to /usr/local. If you are just referring to fixing the permissions with chown, that will require sudo (and admin account).

OS X Yosemite - Vagrant: Failed to install / update plugins (ruby invalid option -H)

I've done a fresh install of OS X Yosemite and Vagrant on my Mac some days ago. The problem is, that every time when I try to update all plugins or install a vagrant plugin (vagrant-cachier), I'll get the following error:
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/vagrant/embedded/bin/ruby extconf.rb
/opt/vagrant/embedded/bin/ruby: invalid option -H (-h will show valid options) (RuntimeError)
If I install a gem over the system's binary it works. So it seems to be a problem with the built-in vagrant binaries. I've also already installed the command line tools. My Vagrant Version is 1.7.2
I've already googled the problem for hours, but I didn't find this problem.
Did I forget anything or does anybody has a workaround for this problem?
Thanks!
Thanks for your help. I found the problem.
The problem was the path were Vagrant is installed. My SSD partition on OS X is called "Macintosh SSD" with a space in it.
I renamed it to "MacintoshSSD" and now it works fine.
The issue appears to be that the 'embedded' binary of ruby is not happy with some older code in the JSON gem. Or something... I literally know nothing about ruby other than that it is a programming language and I installed it to use compass. And now here it is again with Vagrant.
ANYWAY I moved the embedded ruby to the side, and copied OS X's built-in ruby into the vagrant embedded binaries folder.
Something like:
sudo mv /opt/vagrant/embedded/bin/ruby /opt/vagrant/embedded/bin/ruby.2.0.0.p598
sudo cp /usr/bin/ruby /opt/vagrant/embedded/bin/ruby.2.0.0.p481
sudo ln -s /opt/vagrant/embedded/bin/ruby.2.0.0.p481 /opt/vagrant/embedded/bin/ruby
sudo vagrant plugin install vagrant-vmware-fusion
Installing the 'vagrant-vmware-fusion' plugin. This can take a few minutes...
Installed the plugin 'vagrant-vmware-fusion (3.2.1)'!
Yay.
Straight from HashiCorp... here is the troubleshooting checklist:
Hey there,
I am really sorry you are having problems installing that Vagrant plugin. We are aware of these issues, but we have not been able to narrow it down to a specific cause because it only affects a small subset of machines and we have not identified a common denominator yet.
First, please do not try and install the plugin using sudo. This can tamper with the permissions of other Vagrant plugins and cause Vagrant to error.
Second, please ensure you have the XCode Command Line Tools installed. You can install them by running:
sudo xcode-select --install
and following the on-screen prompt.
After completing those steps, many users have found success by doing the following:
Completely uninstall Vagrant
Removing the /opt/vagrant and /Applications/vagrant directories.
Remove Vagrant's storage directory (~/.vagrant.d). Warning: If you
have installed other Vagrant plugins or Vagrant plugin licenses,
they will be removed!
Reinstall Vagrant from the official Vagrant installers:
https://www.vagrantup.com/downloads.html
Install the plugin
Additionally, please ensure the following:
If there is a special character anywhere in Vagrant's path, you must
choose a different directory. This includes spaces (like in a
username or folder name) and parenthesis (like C:/Program Files
(x86)). Unfortunately there is a bug in the language in which Vagrant
is written that prohibits compiling native extensions under these
circumstances.
If you are using a Mac, please make sure you have accepted the XCode
license agreement. In some situations, native extensions will fail to
compile because XCode is prohibiting the installation due to an
unaccepted license agreement. To accept the license agreement, simply
open XCode - you will be prompted if you need to accept the
agreement.
If the problem persists after taking these steps, please provide the output of the plugin installation's debug logs.
Please let me know if you have any questions.
Best,
Seth

Using rbenv doesn't work with sudo?

Any commands that use sudo don't seem to work with RBenv.
I'm trying to install ActiveRecord and it says I don't have write permission, so when I try this:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /usr/local/rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1 directory.
It says:
sudo: gem: command not found
How can I get around this?
The idea behind tools like rbenv and RVM is that you don't need to use sudo, because your entire Ruby environment exists inside your own workspace as a sandbox.
RVM allows multi-user configurations though it was originally designed for single users.
As far as I've ever seen or read, rbenv is single-user only. At no time should you need to use sudo to manipulate or change your Ruby environment when using rbenv. If you do, something is wrong. If you try to use sudo, you'll screw things up. You might not find out immediately but eventually something will pop up and you'll need to change the ownership of the files back to you.
On Linux and Mac OS you can do that pretty easily using:
sudo chown -R <your_user_name>:<your_group> ~/.rbenv
You have to run that as sudo because only the super-user can change ownership of files owned by root. sudo escalates your privileges to allow you to change those things.
I realise this is kind of old now, but this may help people in future:
rbenv-sudo is a plugin for rbenv that allows you to run rbenv-provided Rubies and Gems from within a sudo session.
https://github.com/dcarley/rbenv-sudo
My answer in "Installing Ruby 2.0 and Rails 4.0.0beta on AWS EC2" might be useful to you.
In short, the root user needs to have rbenv loaded in its environment for you to use the gems installed by rbenv. This can be done by adding the following
# /etc/profile.d/rbenv.sh
export RBENV_ROOT=/usr/local/rbenv
export PATH="${RBENV_ROOT}/bin:$PATH"
eval "$(rbenv init -)"
This should be sufficient for sudo to work. If you are writing a shell script, you might need to use
. /etc/profile.d/rbenv.sh
before using executables from other gems.
My answer is a little bit late but I have simple solution for this issue. Use symbolic links to be able use binstubs and other Ruby stuff.
ln -s ~/.rbenv/bin/rbenv /usr/local/bin/rbenv
ln -s ~/.rbenv/shims/* /usr/local/bin
I hope that helps to other users who is having the same issue.

Error when launching AppScale Instances: /usr/bin/ruby: bad interpreter: No such file or directory

I am trying to launch some AppScale Instances. When I try to execute
/bin/appscale-run-instances
I get an error like this:
-bash: bin/appscale-run-instances: /usr/bin/ruby: bad interpreter: No such file or directory
The Image that I'm trying to run is a KVM image (I'm trying to create a Virtual cluster).
What does this error mean? Is there something wrong with my Ruby installation?
this means that one of these things is happening:
You have a broken Ruby installation
You have more than one Ruby installation
Your installation has not been configured properly.
To identify if this is the first case, you can run ruby and see if you get any response.
If you don't, your installation is broken and you need to reinstall it. If you do, you then run which ruby. This should give you the absolute path to your Ruby executable. If this is anything other than /usr/bin/ruby then homebrew (and a bunch of other programs) will not be able to find it.
In case you have not ever tampered with your Ruby installation, you can check to see if /usr/bin/ruby already exists or not: cat /usr/bin/ruby. If you get No such file or directory, then you can easily create a symbolic link to your Ruby installation. Assuming the output of which ruby to by /usr/local/bin/ruby, you create the symbolic link this way: sudo ln -s /usr/local/bin/ruby /usr/bin/rubyand all should be well.
If there is a file at that location, you can run file /usr/bin/ruby to see if it's a real file, a symbolic link, or a curropted file. If it is a symbolic link, your installation should be working, and since it's not, it probably is either a corrupted symlink or it's a bogus file.
You can remedy that by first deleting it (sudo rm /usr/bin/ruby) and then creating a new symlink to the correct location (sudo ln -s /usr/local/bin/ruby /usr/bin/ruby).
If non of the above works, you should consult the homebrew team after a clean install of Xcode and removing any traces of a Ruby installation on your system.

Resources