Hi People I am trying to install a gem file through command prompt on MAC using the following command "gem install filename" but whenever I try to execute the command I get the following error
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/hemmanshu/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing frank-cucumber-0.8.14:
cucumber requires gherkin (~> 2.10.0, runtime)
every time I try to execute this command the same thing pops up.
You need to install gems with superuser privileges so you should to use
sudo gem install [gemname]
instead of
gem install [gemname]
U try with sudo. like "sudo gem install filename"
...Most of the time this is a PATH issue, Suppose you are using zshell as me, then add this line at the end of ~/.zshrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
If you are using bash as default shell then add this line to end of ~/.bashrc file
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
For your case it will be like this:
export PATH="$PATH:$HOME/.gem/ruby/1.8/bin
Lastly don't forget to reload the shell by source ~/.zshrc incase of z-shell or source ~/.bashrc incase of bash-shell. I think this helps someone.
Related
This all started by attempting to install cocoapodsthrough the terminal. Long story short, I kept getting an error that my rubygems version was not acceptable. I then attempted to update that version but kept getting the error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
I found a solution that worked: sudo gem install -n /usr/local/bin rubygems-update
The issue is that now EVERY time I install anything via terminal, I have to use sudo gem install -n /usr/local/bin. Which I do not remember ever being the case (but I may be incorrect). Is there a solution to negate having to enter in that full line every time I install something via terminal? Thanks for any help!
I'm not well versed in terminal, but I'll try my best to make this as clear and concise as I can.
I'm trying to install SASS and get the following errors:
When using gem install sass I get .
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
When using sudo gem install sass I get .
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
I have Xcode installed and I have agreed to the terms.
I even tried updating my Ruby, but terminal tells me I already have the most updated version.
ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
The worst part of all of this is that when I navigate to my Ruby/Gems/2.3.0/gems directory, there is a sass-3.5.5 folder!!! (linked image to follow)
Ruby directory path to sass folder
I try running sass -v and get -bash: sass: command not found
I feel like I've tried everything that I can think of or find online. I'm at a loss and definitely need some help.
The issue can be fixed by installing RVM or Rbenv for managing ruby versions and gems.
Also, FilePermissionError can be fixed using the -n parameter
sudo gem install sass -n /usr/bin
I prefer not touching sudo command, so I managed to solve this issue by referring to SASS home page:
If you use Node.js, you can also install Sass using npm by running
npm install -g sass
If you find it helpful, kindly upvote or leave comment so that I know it can solve your issues too.
Or one could update the directory for where gems are installed.
Please see the origional answer here: https://stackoverflow.com/a/2619731/3302764
export GEM_HOME=~/.gem
export GEM_PATH=~/.gem
I have been trying to install jekyll and bundler, and I keep getting this error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I have tried so many things suggested by other posts. Ran rbenv, appended eval "$(rbenv init -)" to my bash_profile in order to run it automatically, did some stuff with sudo, and also tried installing using:
gem install jekyll --user-install
but then when I try to make a jekyll command the return is:
-bash: jekyll: no command found
I am at a loss. I know basically nothing about Unix and have been trying this for hours. Any thoughts?
P.S. Please do not mark as duplicate because other posts have not answered my question.
It seems you haven't add the user gem bin dir to the PATH.
ruby -rubygems -e 'puts Gem.user_dir'
this will show the gem user dir.
then add OUTPUT_FROM_LAST_CMD/bin to your path, or simply add
export PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin":$PATH
to your ~/.bashrc
http://guides.rubygems.org/faqs/#user-install
I'm trying to install rubyrep on CentOS, and when executing sudo gem install rubyrep I get the error sudo: gem: command not found. Sudo and gem are both installed and working, just not when combined.
My setting:
[rubyrep]# which sudo
/usr/bin/sudo
[rubyrep]# which gem
/usr/local/rvm/rubies/ruby-2.1.2/bin/gem
[rubyrep]# which ruby
/usr/local/rvm/rubies/ruby-2.1.2/bin/ruby
[rubyrep]# $PATH
-bash: /usr/local/rvm/gems/ruby-2.1.2/bin:/usr/local/rvm/gems/ruby-2.1.2#global/bin:/usr/local/rvm/rubies/ruby-2.1.2/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin: No such file or directory
Try without sudo. You should only use sudo if you did a root installation of ruby, which is not recommended.
From http://web.archive.org/web/20130405074724/http://www.kleinfelter.com/node/188:
There are hundreds of reports on the net about "sudo: gem: command not
found". Out of the dozen or so I looked at, the suggested resolution
amounted to "ensure that 'gem' is in your PATH."
Yep. It is in my path. That is to say, the following works:
gem --help
but the following fails:
sudo gem --help
Further confusing matters, gem is in the path shown by:
sudo echo $PATH
The trick is that sudo doesn't use $PATH for its path on some editions
of Linux. This behavior is considered "more secure." (See
sudo changes PATH - why? ).
Bah! It is still a pain to work around. You have to get 'gem' into
the path (not simply the $PATH!) You'll read about options you can
pass to sudo, and that is fine and dandy when you type the
command-line yourself. When someone's script invokes sudo for you,
you're stuck with the command line that it uses.
I fixed it by doing:
alias sudo='sudo env PATH=$PATH'
as suggested in sudo changes PATH - why?.
sudo env PATH=$PATH gem install rails
It works for me.
If anyone runs across this, like I did, and the without sudo isn't an option. You may want to check your sudoers for the 'secure_path'.
If this doesn't include the path of your installation/gem/ruby (which gem). Then you'll also get this error.
Fedora 23, built from source.
This might seem stupid, but I recently tried to install SASS and followed their instructions:
$ gem install sass
$ sass --watch [...]
So I followed along:
root#server:~# gem install sass
Successfully installed sass-3.1.15
1 gem installed
Installing ri documentation for sass-3.1.15...
Installing RDoc documentation for sass-3.1.15...
root#server:~# sass
bash: sass: command not found
Despite looking around like an idiot trying to find some simple way to run something like gem run sass or some other workaround to make it function, I am more or less at a loss.
It seems that Debian/Ubuntu drops ruby gems into /var/lib/gems/1.8/bin.
So the solution (at least for Ubuntu/Debian) is:
$ sudo -s
# echo 'PATH=/var/lib/gems/1.8/bin:$PATH' > /etc/profile.d/gemspath.sh
# chmod 0755 /etc/profile.d/gemspath.sh
...and then open a new shell session.
(This is fixed in Ubuntu 11.10.)
If you happen to have installed Ruby through rbenv, you'll need to execute the following command
rbenv rehash
On macOS I had to add the gem executable directory to the path.
Add these lines to your ~/.bashrc file, and reopen the terminal to refresh the env vars.
# gem
gembin=`(gem env | sed -n "s/.*EXECUTABLE DIRECTORY: \(.*\)/\1/p")`
export PATH=$gembin:$PATH
If you use macOS and you:
I don't know/care about Ruby.
I just want to run this program.
Why is this so complicated?
Then run:
~/.gem/ruby/*/bin/jekyll
where jekyll is the thing you just installed with gem install.
If you're trying to run a simple WEBrick server for your gem you can do the following after installation:
sass start