After upgrading to Mac OS Big Sur, I saw this error I haven’t seen before:
After this I was able to install the rails gem successfully (without needing to do sudo) Solution no. 10: I run into a similar problem on my Mac while trying to install watchr package. ERROR: While executing gem (Gem::FilePermissionError) Somehow running sudo every time I need to install a package felt excessive. And with a specific version: brew gem install heroku 3.8.3 -homebrew-ruby. To upgrade: brew gem upgrade heroku. To uninstall: brew gem uninstall heroku. To check information: brew gem info heroku. Note: Installed gems are listed in brew list with prefix of gem-, like gem-heroku.
So I ran bundle install
but it didn’t seem to work either. An excerpt from the terminal output:
After some research and trial and error, I found this precious answer in Stack Overflow that it is due to the Ruby version that is not compatible with BigSur and it should be at least 2.7. So Ichecked Ruby releases and decided to go with one of the most recent releases: 2.7.2.
Anyway, steps I think worked:
And it worked!
Installing Ruby through Homebrew: didn’t solve the issue but I don’t know if this actually and eventually helped or not.
Installing the latest version of Ruby (ref) using rvm: didn’t update the version for some reason.
I have checked all the other similar answers and none was exactly like mine, neither did any of those solutions work for me.
gem environment and sudo gem environment give the same result:
rvm -v : rvm 1.22.3
ruby -v : ruby 1.8.7
OSX 10.8.4
echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/ava/.rvm/bin:/home/ava/bin
gem install
whereas I am able to install the same via sudo. What am I doing wrong?
UPDATE:
As per comments and this post, I ran following:
rvm implode and then re installed the stable version.
rvm install 1.9.3 or any other ruby installation fails with
make.log
To resolve the error:
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions into the /usr/local/lib/ruby/gems/1.8 directory.
the following solution worked for me:
ERROR: While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
.zshrc
, .bashrc
etcgem i LIBRARY_NAME
Your global (system-wide) config file probably has the --no-user-install
flag set. Create/edit your local ~/.gemrc
file and append the following line(s):
Note
The actual directory for the gemdir
option will vary depending on your system/desire; it may or may not be needed, but it’s probably better to designate the desired installation directory within your home
folder (gemdir
) than to assume it’ll be taken care of by itself.
The ArchLinux Wiki has some useful/well-organized information pertaining to this.
Alternatively, similar to the rvm
solution already suggested, you can try using chruby to maintain, configure, and use local versions of ruby
. To install additional versions of ruby
, however, you need to use ruby-install.
From the project’s README:
Changes the current Ruby. Features
Updates $PATH.
Also adds RubyGems bin/ directories to $PATH.
Correctly sets $GEM_HOME and $GEM_PATH.
Users: gems are installed into ~/.gem/$ruby/$version.
Root: gems are installed directly into /path/to/$ruby/$gemdir.
Additionally sets $RUBY_ROOT, $RUBY_ENGINE, $RUBY_VERSION and $GEM_ROOT.
Optionally sets $RUBYOPT if second argument is given.
Calls hash -r to clear the command-lookup hash-table.
Fuzzy matching of Rubies by name.
Defaults to the system Ruby.
Optionally supports auto-switching and the .ruby-version file.
Supports bash and zsh.
Small (~100 LOC).
Has tests.
Anti-Features
Does not hook cd.
Does not install executable shims.
Does not require Rubies be installed into your home directory.
Does not automatically switch Rubies by default.
Does not require write-access to the Ruby directory in order to install gems.
Requirements
bash >= 3 or zsh
If you have installed rvm
as the root user, then you must sudo
to install anything.
You can install rvm
in user-mode as a regular user, in which case everything is stored in your home directory and no sudo
is required.
If you are not committed to this particular install, type sudo rvm implode
and start over.
assuming that rvm is installed you could do something like:
No need to do sudo.
If you have installed rbenv & facing this error, below answer will help (this is how it worked for me)
Issue:
DO NOT USE SUDO
Here, you can see, by default it selected system. change it to your ruby version.
Then try installing the bundler, it will work:
You probably don’t have write permissions to somewhere along that path, (most likely /usr/local/lib), you need to change the location of your RVM storage in order to not need sudo
Be aware that if you chose to perform a multi-user install of rvm, you must add each user to the rvm group via
Relevant info from rvm’s FAQ
I encountered the same error yesterday when I tried to install rails using following command.
Prior to this I had installed Ruby Environment Manager (rbenv), but the following command failed to add the if-eval to bash profile.
So, I looked into this and found out that the current directory reference – was the problem for the above command to fail. I changed it to ~ and successfully ran the below command
After this I was able to install the rails gem successfully (without needing to do sudo)
I run into a similar problem on my Mac while trying to install watchr package
ERROR: While executing gem … (Gem::FilePermissionError)
Somehow running sudo every time I need to install a package felt excessive. I have rbenv installed so I set global ruby version like this
Then simply installed the package I wanted. In my case the command is