Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

ruby - Can "gem install" be configured to install executables outside /usr/bin/ by default?

By default, when you sudo gem install thegemname it will install executables into /usr/bin/

Is there a way to change this? For example, to install them into /usr/local/rubygems/bin (or any other path)?

The path doesn't seem to be hard-coded into the gemspec file, so I don't see why this shouldn't be possible (although I have very little experience with Ruby/Gems)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm adding this as an answer so that it is obvious when I run into this problem again :)

First, move all the bins in /var/lib/gems/1.8/bin/ to /usr/bin/. If you don't do this, then uninstalling or updating a gem will not remove the binary from the original bin directory.

You may also wish to remove the old path from $PATH

Next, edit ~/.gemrc and add (or update) the following line:

gem: --bindir /usr/bin

This overrides gem so that it always uses /usr/bin/ as the bin dir.

No need to update the path (especially messy for multiple-user machines).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...