I am trying to install bundler and I get the following error.
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I have poked around on this site and other places and found the common suggestion to install rbenv, which I did using homebrew. I also added Add rbenv init to my shell using the following command:
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
I then started a new shell so that PATH changes take effect then checked if rbenv was set up:
$ type rbenv
#=> "rbenv is a function"
All good so far.
Then I try to install bundler again using the gem install bundler and I still get the error
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
I have also been experiencing problems with my Python setup and I suspect this is symptomatic of the same root cause, but I'm not sure what to do next. Any ideas?
I'm running Mac OS X 10.9.1
Try making your directory permissions less restrictive with chmod or Finder > File > Get Info. Also, check that your umask isn't more restrictive than you want.
Definitely avoid changing permissions, especially since rbenv is possibly using the system's ruby. Instead you should have your own ruby, locally, with rbenv. Somewhere rbenv is still using the root owned system's version instead of your local PATH.
OP should be able to install local gems instead of system-wide ones.
See stackoverflow.com/a/23510249/1899424 – dcorking Feb 29 at 10:52
This helped put me in the right direction resolving the same issue you've encountered. Still trying to get snorby.
Related
I have installed ruby (2.7.0) using
snap install ruby
before this, I removed ruby 2.3.0 by deleting all its files, after
sudo apt-get remove ruby
but now the gem command just doesn't work. I have reinstalled it, but whenever I use gem, I get this message,
bash: /usr/local/bin/gem: /usr/local/bin/ruby: bad interpreter: No such file or directory
Ruby is currently installed in
/snap/bin/ruby
Your system PATH is determining the wrong direction for gem.
PATH is an environment variable on Unix-like operating systems, DOS, OS/2, and Microsoft Windows, specifying a set of directories where executable programs are located. In general, each executing process or user session has its own PATH setting. (Wikipedia)
You can fix the problem by finding out which directory is being prioritized using which -a gem, then re-ordering your PATH.
I made a script to achieve this, here: reorderPathForExe.sh
To run this script, just use git clone and chmod +x, then pass the executable you want fixed as the argument to reorderPathForExe.sh (i.e., ./reorderPathForExe.sh gem for you):
git clone https://gist.github.com/f4f83b23386111bedd7f8199949601af.git
cd ./f4f83b23386111bedd7f8199949601af
chmod +x ./reorderPathForExe.sh
./reorderPathForExe.sh gem
you should probably be installing ruby with RVM or rbenv.
When I create a scaffold in terminal, I get the above error message. I have type the following command first:
echo "source \$HOME/.rvm/scripts/rvm" >> ~/.bashrc
I still get the following error:
WARNING:root:could not open file '/etc/apt/sources.list.d/passenger.list'
The program 'rails' is currently not installed. You can install it by typing:
sudo apt install ruby-railties
Any help will be greatly appreciated.
Try running the command source ~/.bashrc and then re-running rails. If that doesn't work, a different approach may be needed.
The problem is that as far as your OS is concerned, Rails doesn't exist. There could be multiple reasons for this. Seeing that you're using rvm, rvm is supposed to tell Ubuntu where to find rails.
Make sure that you are using the correct version of ruby specified in your Gemfile by typing rvm current. Make sure you are using the correct version when running bundle install, otherwise the gems will be installed under a different ruby version.
Also, make sure that the ~/.rvm directory exists and that the path specified in your .bashrc file is correct.
Let me know if any of these suggestions help.
I am very new to Ruby on Rails. I have installed ruby, rails, gems, and RVM (and possibly some more RoR-associated files) via Mac OS terminal.
When I first installed these softwares, they seemed to work fine, and I could execute command lines like:
rails new 'project' or rails server
But then I messed around with git, directory, and some sudo bundle/gem commands a little bit because "bundle install" command wouldn't work. Honestly, I don't know what I have done, but all of these command lines have stopped working now.
They output various error messages, such as:
1) There was an error parsing 'Gemfile': Undefined local variable or method for Gemfile. Bundler cannot continue.
2) bash: /usr/local/bin/rails: /usr/local/opt/ruby/bin/ruby: bad interpreter: No such file or directory
3) ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions
4) find spec_for exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
I think there were more errors, but these are all I can remember for now. Obviously, I am getting some intimidating error messages that I don't understand.
So I have come to a conclusion that I should uninstall all Ruby, Rails, Gems, RVM, and Homebrew files. But even this task looks very challenging to me.
I have tried numerous command lines in an attempt to delete them, but when I type in "rails" on spotlight, I still see lots of rails-associated files. Also, when I type "ruby -v" on terminal, it is still showing the ruby 2.0.0p648 version.
When I type in "which ruby" on terminal, it says "/usr/bin/ruby
When I type in "which rails" on terminal, it says "usr/local/bin/rails
In short, I just want to delete all of these RoR-related files, softwares, and every trace of them, and reinstall them clean. Please please help me. I do not want to give up coding. Is it too late to say that I'm sorry?
#This is my .bash_profile
# Enable tab completion
source ~/.profile
# colors!
green="\[\033[0;32m\]"
blue="\[\033[0;34m\]"
purple="\[\033[0;35m\]"
reset="\[\033[0m\]"
# Change command prompt
source ~/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
# '\u' adds the name of the current user to the prompt
# '\$(__git_ps1)' adds git-related stuff
# '\W' adds the name of the current directory
export PS1="$purple\u$green\$(__git_ps1)$blue \W $ $reset"
alias subl="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
~
"~/.bash_profile" 21L, 720C
Ruby is installed on OS X by default. So you don't want to remove that, there are things that might require ruby that has nothing to do with rails or your rails projects, you should ignore it. (and you should probably not use spotlight for finding dev files, its just confusing as to what is safe and what is not to play with)
Secondly, you'll hardly EVER use sudo for any rails-related work on your mac, so if a tutorial wants you to run that command, don't.
And lastly, its possible it's not as bad as you think. So there's 2 steps. 1 - Fix your rvm environment and 2 - fix your gemfile
TO RESOLVE
--Start be reinstalling RVM
\curl -sSL https://get.rvm.io | bash
Now because it's changed your shell environment (added variables and aliases) and because you've changed some things that are unpredictable... Log out, and log back into your mac.
** Which ruby is in use now? **
which ruby
If you're system is still showing /usr/bin/ruby then you'll need to edit your shell profiles. Because I don't know what you might have done, or what shell env you're using I'll just be thorough. Any excess won't hurt.
You'll review (in the editor of your choice) 4 hidden files in your home directory
/Users/yourhome/.profile
/Users/yourhome/.bashrc
/Users/yourhome/.zshrc
/Users/yourhome/.bash_profile
If you're using bash, then make sure your bash_profile has in it
source ~/.profile
In the bashrc nad zshrc files make sure the rvm path exists
export PATH="$PATH:$HOME/.rvm/bin"
In the .profile file make sure this command exists
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
-- Once you've saved your changes, log out and back in (you shouldn't have have to do this but again, just being thorough).
Once that is done, you should be able to install a ruby -
rvm install ruby-2.2.3
Now if you say rvm use ruby-2.2.3 and then which ruby, you should see a pointer to your home directory where rvm lives.
* Now to fix the Gemfile *
You have an encoding problem, which is what caused you the errors that made you see spots in the first place. If you paste the contents of the file here
(in a terminal in the directory of your rails project)
cat Gemfile
Paste those contents here and it can be fixed.
I am doing the Ruby on Rails 4 essential training with Kevin Skoglund. I installed Xcode and Homebrew no problems, was following along just fine when I went to do the command rbenv global 2.3.0 to change to the newest version, it won't do it. I was instructed to logout and back in, i shut down and restarted and I am still in version 2.0. How do I get it to change? I am a super noob, but I am brave. I would love to figure this out so i can get started.Also, i went to update my gems and this happened,
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
So I was stopped dead in my tracks, any help will be much appreciated
It's probably the case you missed a step on the rbenv installation. Unless the stub is installed in your .bash_profile (or equivalent), then rbenv won't engage on your shells properly.
Try repeating step two on the Basic GitHub Checkout step:
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
Then check that it's installed correctly:
type rbenv
Which should be a function.
What you're describing is probably a $PATH issue where the system Ruby is taking priority. The rbenv one needs to come first.
I'm trying to comprehend the Unix file system on my OSX. I'm following wikipedia Filesystem Hierarchy Standard.
I understand when I install ruby gems I must use the command sudo gem install but if I omit sudo, problems may occur.
Where are gems installed within the file system when I omit sudo?
How can I delete these gems?
A Fun side question: When I enter cd ~/.gem my terminal is directed to .gem user$, When I enter cd ~/ and list folders using the ls command I can't find a .gem folder. Where is the .gem folder? How does this fit into the Filesystem?
Ok, looking over the Ruby Gems documentation http://docs.rubygems.org/read/chapter/3
the default install directory is:
/usr/local/lib/ruby
Ruby gems uses the environment variable GEM_HOME for the install path. You can change this via the export command like so:
$ export GEM_HOME=/home/mygemrepository $ ruby setup.rb —prefix=/home/mystuff
You can uninstall gems with the gem uninstall command:
gem uninstall gemtouninstall
Finally, as I already mentioned files/folders starting with . (such as .bashrc) are hidden from ls by default, so use the ls -a option to see them. You can read more here: http://unixhelp.ed.ac.uk/CGI/man-cgi?ls
Also, sudo is basically saying, "Do this action as if I was the root user," where the root user is essentially like the highest level administrator. It's a common thing to do when installing software via the command line.