问题描述:

I have updated all the brew formulas with brew update && brew upgrade. I after I upgrading I noticed that rails is not found but when I type

which rails

it returns /usr/bin/rails. All I can guess is I have to add rails path to .zshrc again. But, I am not sure what all I need to add to .zshrc file.

What are all the things that update broke.

.zshrc file

# Adding bin to PATH for sublime

export PATH="$PATH:~/bin"

# Rbenv stores data under ~/.rbenv by default. If you absolutely need to

# store everything under Homebrew's prefix, include this in your profile:

export RBENV_ROOT=/usr/local/var/rbenv

# MongoDB

export MONGO_PATH=/usr/local/Cellar/mongodb/3.0.7

export PATH=$PATH:$MONGO_PATH/bin

# Ruby Motion android tool

export RUBYMOTION_ANDROID_SDK=/Users/abhimanyuaryan/.rubymotion-android/sdk

export RUBYMOTION_ANDROID_NDK=/Users/abhimanyuaryan/.rubymotion-android/ndk

export DOTFILES=$HOME/.dotfiles

export ZSH=$DOTFILES/zsh

# display how long all tasks over 10 seconds take

export REPORTTIME=10

[[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo

# define the code directory

# This is where my code exists and where I want the `c` autocomplete to work from exclusively

if [[ -d ~/code ]]; then

export CODE_DIR=~/code

fi

# source all .zsh files inside of the zsh/ directory

for config ($ZSH/**/*.zsh) source $config

if [[ -a ~/.localrc ]]; then

source ~/.localrc

fi

# initialize autocomplete

autoload -U compinit

compinit

for config ($ZSH/**/*completion.sh) source $config

export EDITOR='nvim'

export PATH=/usr/local/bin:$PATH

# add /usr/local/sbin

if [[ -d /usr/local/sbin ]]; then

export PATH=/usr/local/sbin:$PATH

fi

# adding path directory for custom scripts

export PATH=$DOTFILES/bin:$PATH

# check for custom bin directory and add to path

if [[ -d ~/bin ]]; then

export PATH=~/bin:$PATH

fi

[ -z "$TMUX" ] && export TERM=xterm-256color

# install rbenv

if hash rbenv 2>/dev/null; then

eval "$(rbenv init -)"

fi

if [[ -d ~/.rvm ]]; then

PATH=$HOME/.rvm/bin:$PATH # Add RVM to PATH for scripting

source ~/.rvm/scripts/rvm

fi

# alias git to hub

if hash hub 2>/dev/null; then

eval "$(hub alias -s)"

fi

# source nvm

export NVM_DIR=~/.nvm

if hash brew 2>/dev/null; then

source $(brew --prefix nvm)/nvm.sh

source `brew --prefix`/etc/profile.d/z.sh

fi

# Base16 Shell

# if [ -z "$THEME" ]; then

export THEME="base16-eighties"

# fi

if [ -z "$BACKGROUND" ]; then

export BACKGROUND="dark"

fi

BASE16_SHELL="$DOTFILES/.config/base16-shell/$THEME.$BACKGROUND.sh"

# [[ -s $BASE16_SHELL ]] && source $BASE16_SHELL

source $BASE16_SHELL

export NVM_DIR=~/.nvm

. $(brew --prefix nvm)/nvm.sh

# Online help for ZSH

unalias run-help

autoload run-help

HELPDIR=/usr/local/share/zsh/help

网友答案:

The only solution I came across is to re-install ruby & rails. I think while upgrading rbenv existing install somehow got removed

# Install Ruby
rbenv install 2.2.3
rbenv global 2.2.3
ruby -v

gem install rails -v 4.2.4

rbenv rehash

rails -v
# Rails 4.2.4
网友答案:

Most likely you have Rails squirreled away in some particular gemset in some rvm-managed Ruby version, but you haven't told rvm to use it again yet.

Look at your installed Ruby versions (with rvm list). Chances are that the one you were using before is still there. If you recognize one, use it (with rvm use ruby-2.2.4 or whatever version), else start looking in all the versions.

For each Ruby version you inspect, look at the gemsets rvm is managing under it (with rvm gemset list). Chances are, you either created one for some Rails project, or as a starter for Rails projects in general (that's what I do), or maybe you just left all the gems to be installed into the default or global gemsets.

If you recognize a particular one, use it (with rvm gemset use rails_4_2 or whatever gemset name), else start looking in all the gemsets. You'll eventually find the right combination.

If you don't, then go through the same process as from scratch. First make sure you're using the Ruby version you want (you may need to install it, with rvm install 2.3 or whatever version). Then create a new gemset (with rvm gemset use --create rails_4_2 or whatever you want to call it). Lastly, gem install rails.

相关阅读:
Top