Ruby gems not available - mac, probably PATH issue

2019-09-08 10:37发布

The Problem

I can't install ruby gems properly, here's what I get trying to install and run chef:

$ gem install chef && chef
Successfully installed chef-11.6.0
Parsing documentation for chef-11.6.0
1 gem installed
bash: chef: command not found

My path is:

$ echo $PATH
/Users/mcarey/.rvm/gems/ruby-2.0.0-p0/bin:/Users/mcarey/.rvm/gems/ruby-2.0.0-p0@global/bin:/Users/mcarey/.rvm/rubies/ruby-2.0.0-p0/bin:/Users/mcarey/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/mcarey/.rvm/gems/ruby-2.0.0-p0/gems

Background/History

It was all working fine until I accidentally (long story short) created a tilde (~) directory and then tried to remove it with 'rm -R ~', this of course started deleting my home directory but once it hit the first protected file it asked for permission and I cancelled it. My old ~/.bash_profile was removed but I'm not sure what else went.

Any thoughts? Any extra info needed?

标签: ruby macos gem
1条回答
成全新的幸福
2楼-- · 2019-09-08 11:20

If you deleted your ~/.bash_profile file, I think that Gems will work until you fix your path in this new file. So :

  1. Be sure that you have recreated your ~/.bash_profile file in your home folder (terminal command : mate ~/.profile)
  2. Check if this line exists export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
  3. if this line does not exist, add this in your file
  4. save the file
  5. To check if the file is correct input . ~/.profile in the terminal

I guess your probleme is only a path problem but if you face with another problem here is a link where to find more info

But if your path is correct you can try to use your gem this way:

  1. Go to your application root folder
  2. bundle install
  3. bundle exec bower

=> MAYBE THIS CAN HELP : Checking documentation in github and google, ifound this article there is a possibility to use the bower-rails gem.

in your Gemfile:

gem "bower-rails", "~> 0.4.4"

I hope this will help :)

查看更多
登录 后发表回答