"You don't have [PATH ]in your PATH, gem executables will not run." while using "gem install --user-install bundler"

Viewed 43671

I was trying to install jekyll in my Mac and got the warning as following:

WARNING: You don't have /Users/Carrot/.gem/ruby/2.3.0/bin in your PATH, gem executables will not run.

I checked through gem list and it shows it is installed; and I can find the jekyll through the path "/Users/Carrot/.gem/ruby/2.3.0/bin". I read a post which seems like my situation. I would like to know if it's a must to go through sudo? I now prefer to uninstall everything (since it also installed sass and bunch of things at the same time) and go through homebrew. How can I do the uninstallation?

Many thanks!

5 Answers

For those who have problems with @lamech-desai answer, (actually, when they do Desai's commands, it apparently works temporarily for them). So you can easily do these:

open ~/.bshrc if you would like to use bash or ~/.zshrc if your are using zsh or etc...

$ sudo nano .bashrc    ## bash users
$ sudo nano .zshrc     ## zsh users

then copy and past these two lines of codes at the end of the .*rc file:

export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"

then simply press ctrl+s and ctrl+x. This will save the changes to .bashrc but you won't see them immediately - directly on your next shell login with your current user. One way to see the changes immediately is to switch user to root with su root and then switch back to your previous user with su <username> - and voila, your .bashrc will be reloaded. You can also check this with echo $PATH.

Thanks to @lamech-desai for great answer

If you are using arch linux just use the commands below in your terminal

[user~]$ export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
[user~]$ export PATH="$PATH:$GEM_HOME/bin"
[user~]$ gem list
[user~]$ gem update

If you are on a Mac like me, you need to add the PATH to the PATH environmental variable. You can do it with export command:

export PATH="/Users/Carrot/.gem/ruby/2.3.0/bin:$PATH"

If you wanna know more about this process, here is a blog post about this: Adding a Path to the Linux PATH Variable

Probably a bit odd to answer my own question but I did finally fix it somehow like a blind fly. I hope to write down the experience maybe who else is totally like me as a absolute beginner with everything wouldn't get struggling overnight.

Stage 1: from gem to homebrew (failed)

At the beginning, I did remove items that install in gem item-by-item, then I install brew-gem to do it. At some stage, it work for jekyll but not my theme. It kept popping out I didn't install a package that the theme needs even I installed it manually. So in the end, I remove everything related to jekyll from homebrew.

Stage 2: back to gem (very long path but finally made it)

I later found a page tell step-by-step to install jekyll. I am using OSX 10.13 (High Sierra) that cause me the permission problem. So I just granted access with this line:

sudo chown -R $(whoami) /usr/local/*

The * is a must or it won't work. I did the same to the ruby part

sudo chown -R $(whoami) /Library/Ruby/Gems/2.3.0/*

After that I install jekyll and bundler carefully following the instruction. And install the packages that the theme needs manually through gem install, which you can find at the Gemfile. I got the problem of jekyll-sitemap similar as this, I followed the method to install pygment.rb through gem install pygments.rb. And now my site is locally work.

Related