After a number of misadventures involving RVM, Ruby and Rails on my new laptop have left me completely bewildered. I uninstalled RVM but all the paths, versions and permissions are all messed up.
I searched and couldn't find the right fixes. It feels like each solution makes the problem get worse.
I want to start fresh without having to reset my computer to factory settings. How can I reset just the Ruby-related things like Ruby, Rails, etc., without erasing my computer?
I would close & reopen your terminal window before you start all of this to make sure you don't have any old env vars loaded.
General things:
env | grep RUBY
env | grep RUBY
, env | grep RVM
env | grep RVM
and look for any leftover environment variables that you may have set env | grep GEM
env | grep GEM
. Sometimes you'll see GEM_PATH
, GEM_HOME
, etc. but these aren't necessary for system ruby~/.bash_profile
, ~/.bashrc
, and ~/.profile
files and see if you've added any rvm stuffIf you're running macOS Mojave (I'm comparing against my system):
which ruby
should return /usr/bin/ruby
. If it doesn't, you have something else interfering. Post what that is and we can get it fixed.
Running /usr/bin/ruby --version
should return ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Permissions for system ruby:
-r-xr-xr-x 1 root wheel 52016 Nov 30 02:38 /usr/bin/ruby
This should be something like sudo chmod 555 /usr/bin/ruby
to fix this if yours is difference. If you have different owners you'll need to sudo chown root:wheel /usr/bin/ruby
You'll also want to check which gem
, and see if it reports /usr/bin/gem
. Permissions should be the same as /usr/bin/ruby
. /usr/bin/gem --version
should return 2.5.2.3
Running /usr/bin/gem env
should return something similar-ish to below. Replace jay
(my computer user) with yours
RubyGems Environment:
- RUBYGEMS VERSION: 2.5.2.3
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/jay/.gem/ruby/2.3.0 # this doesn't matter much
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/jay/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/jay/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => false
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["https://rubygems.org/"]
- "benchmark" => true
- "gem" => "--document=yri"
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/bin
- /Users/jay/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
From there you've got two directories you probably want to look at:
Run ls -al /Library/Ruby/
. You should see this:
drwxr-xr-x 3 root wheel 96 Aug 17 18:59 Gems
drwxr-xr-x 3 root wheel 96 Aug 17 18:59 Site
You may need to chmod/chown each of those directories (with -R
for recursive)
When you're done, please note that running /usr/bin/gem install bundler
and gem install bundler
(assuming you haven't installed a new ruby version manager) should yield an error as below (this means you re-configured the permissions correctly).
Fetching: bundler-1.17.2.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
You'll see some tutorials mention changing those permissions, or running sudo to install gems but I don't recommend that. My favorite ruby version manager is asdf which may be worth a look. You'll install the core, and the ruby plugin .
This should get you a little bit closer. If you see anything else messed up, please post the error.
rm -rf ~/.rvm
, then edit ~/.bash_profile
to remove source $HOME/.rvm/scripts/rvm
.
Then you can restart with RVM from scratch by following the detailed installation instructions at https://rvm.io/rvm/install .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.