# Who added this to my $PATH?

**URL:** <https://rubytalk.org/t/who-added-this-to-my-path/53274>\
**Category:** ruby-talk\
**Created:** [7 May 2009 08:08 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274 "2009-05-07T08:08:30Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Albert\_Schlef](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@Albert\_Schlef](https://rubytalk.org/u/Albert_Schlef)\
**Post date:** [7 May 2009 08:08 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/1 "2009-05-07T08:08:30Z")

</div>

I've just found the following line in my ~/.bashrc:

&nbsp;&nbsp;PATH=$PATH:~/.gem/ruby/1.8/bin

Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
goes in ~/.gem/ruby/1.8/bin.

But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
because, IIRC, just today I discovered the fact the RubyGems puts  
binaries there.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [7 May 2009 08:53 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/2 "2009-05-07T08:53:33Z")

</div>

I bet it was you, unless someone else installed ruby-gems ;).  
I agree however that there might be better solutions than to pollute  
your PATH environement variable. But as I am unable to provide one I  
will certainly not complain.

BTW IIANM this does not happen in 1.9 anymore.

Cheers  
Robert

> **···**
>
> On Thu, May 7, 2009 at 10:08 AM, Albert Schlef \<albertschlef@gmail.com\> wrote:
> 
> > I've just found the following line in my ~/.bashrc:
> > 
> > PATH=$PATH:~/.gem/ruby/1.8/bin
> > 
> > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > goes in ~/.gem/ruby/1.8/bin.
> > 
> > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > because, IIRC, just today I discovered the fact the RubyGems puts  
> > binaries there.
> 
> --  
> Si tu veux construire un bateau ...  
> Ne rassemble pas des hommes pour aller chercher du bois, préparer des  
> outils, répartir les tâches, alléger le travail… mais enseigne aux  
> gens la nostalgie de l’infini de la mer.
> 
> If you want to build a ship, don’t herd people together to collect  
> wood and don’t assign them tasks and work, but rather teach them to  
> long for the endless immensity of the sea.
> 
> --  
> Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [8 May 2009 17:24 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/3 "2009-05-08T17:24:29Z")

</div>

It wasn't RubyGems, however RubyGems does warn you if you have --user-install (current default) and don't have the user bin for in your PATH.

I'd be surprised if some other gem added the path for you.

(I wouldn't add the code to do this to RubyGems as there's too many shells to support.)

> **···**
>
> On May 7, 2009, at 1:08, Albert Schlef \<albertschlef@gmail.com\> wrote:
> 
> > I've just found the following line in my ~/.bashrc:
> > 
> > PATH=$PATH:~/.gem/ruby/1.8/bin
> > 
> > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > goes in ~/.gem/ruby/1.8/bin.
> > 
> > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > because, IIRC, just today I discovered the fact the RubyGems puts binaries there.

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [11 May 2009 09:21 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/4 "2009-05-11T09:21:34Z")

</div>

Albert Schlef wrote:

> I've just found the following line in my ~/.bashrc:
> 
> &nbsp;&nbsp;PATH=$PATH:~/.gem/ruby/1.8/bin
> 
> Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> goes in ~/.gem/ruby/1.8/bin.
> 
> But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> because, IIRC, just today I discovered the fact the RubyGems puts  
> binaries there.

How did you install RubyGems? If it came from an O/S package then maybe  
its post-install script did it for you.

BTW, Ubuntu \*didn't\* do this for me - I had to sort out my own path to  
get /var/lib/gems/1.8/bin in there.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [9 May 2009 08:13 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/5 "2009-05-09T08:13:48Z")

</div>

Eric I did not think of RubyGems, but rather of the gem itself. Do you  
think this is possible?  
Cheers  
Robert

> **···**
>
> On Fri, May 8, 2009 at 7:24 PM, Eric Hodel \<drbrain@segment7.net\> wrote:
> 
> > On May 7, 2009, at 1:08, Albert Schlef \<albertschlef@gmail.com\> wrote:
> > 
> > > I've just found the following line in my ~/.bashrc:
> > > 
> > > PATH=$PATH:~/.gem/ruby/1.8/bin
> > > 
> > > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > > goes in ~/.gem/ruby/1.8/bin.
> > > 
> > > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > > because, IIRC, just today I discovered the fact the RubyGems puts binaries  
> > > there.
> > 
> > It wasn't RubyGems, however RubyGems does warn you if you have  
> > --user-install (current default) and don't have the user bin for in your  
> > PATH.
> 
> --  
> Si tu veux construire un bateau ...  
> Ne rassemble pas des hommes pour aller chercher du bois, préparer des  
> outils, répartir les tâches, alléger le travail… mais enseigne aux  
> gens la nostalgie de l’infini de la mer.
> 
> If you want to build a ship, don’t herd people together to collect  
> wood and don’t assign them tasks and work, but rather teach them to  
> long for the endless immensity of the sea.
> 
> --  
> Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [11 May 2009 09:30 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/6 "2009-05-11T09:30:42Z")

</div>

> Albert Schlef wrote:
> 
> > I've just found the following line in my ~/.bashrc:
> > 
> > PATH=$PATH:~/.gem/ruby/1.8/bin
> > 
> > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > goes in ~/.gem/ruby/1.8/bin.
> > 
> > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > because, IIRC, just today I discovered the fact the RubyGems puts  
> > binaries there.
> 
> How did you install RubyGems? If it came from an O/S package then maybe  
> its post-install script did it for you.
> 
> BTW, Ubuntu \*didn't\* do this for me - I had to sort out my own path to  
> get /var/lib/gems/1.8/bin in there.  
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

I reread the OP again and again, because it is obvious (to me now)  
that Eric and you assume that OP did just install Rubygems. He did not  
say so. I still have this strange feeling that some gem did this to  
him. Maybe one he was writing himself?

Cheers  
Robert

> **···**
>
> On Mon, May 11, 2009 at 11:21 AM, Brian Candler \<b.candler@pobox.com\> wrote:
> 
> > 
> 
> --  
> Si tu veux construire un bateau ...  
> Ne rassemble pas des hommes pour aller chercher du bois, préparer des  
> outils, répartir les tâches, alléger le travail… mais enseigne aux  
> gens la nostalgie de l’infini de la mer.
> 
> If you want to build a ship, don’t herd people together to collect  
> wood and don’t assign them tasks and work, but rather teach them to  
> long for the endless immensity of the sea.
> 
> --  
> Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![Eric\_Hodel1](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@Eric\_Hodel1](https://rubytalk.org/u/Eric_Hodel1)\
**Post date:** [9 May 2009 21:41 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/7 "2009-05-09T21:41:24Z")

</div>

It's possible, but it wouldn't happen at install time.

> **···**
>
> On May 9, 2009, at 01:13, Robert Dober wrote:
> 
> > On Fri, May 8, 2009 at 7:24 PM, Eric Hodel \<drbrain@segment7.net\> \> wrote:
> > 
> > > On May 7, 2009, at 1:08, Albert Schlef \<albertschlef@gmail.com\> \>\> wrote:
> > > 
> > > > I've just found the following line in my ~/.bashrc:
> > > > 
> > > > PATH=$PATH:~/.gem/ruby/1.8/bin
> > > > 
> > > > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > > > goes in ~/.gem/ruby/1.8/bin.
> > > > 
> > > > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > > > because, IIRC, just today I discovered the fact the RubyGems puts binaries  
> > > > there.
> > > 
> > > It wasn't RubyGems, however RubyGems does warn you if you have  
> > > --user-install (current default) and don't have the user bin for in your  
> > > PATH.
> > 
> > Eric I did not think of RubyGems, but rather of the gem itself. Do you  
> > think this is possible?

---

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [11 May 2009 09:46 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/8 "2009-05-11T09:46:30Z")

</div>

Robert Dober wrote:

> > > binaries there.
> > 
> > How did you install RubyGems? If it came from an O/S package then maybe  
> > its post-install script did it for you.
> > 
> > BTW, Ubuntu \*didn't\* do this for me - I had to sort out my own path to  
> > get /var/lib/gems/1.8/bin in there.  
> > --  
> > Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
> 
> I reread the OP again and again, because it is obvious (to me now)  
> that Eric and you assume that OP did just install Rubygems. He did not  
> say so. I still have this strange feeling that some gem did this to  
> him. Maybe one he was writing himself?

He didn't say he'd only just installed RubyGems, but he did say that  
he'd only just noticed this extension to his PATH in .bashrc. The fact  
that he'd only just noticed it doesn't necessarily mean that it hasn't  
been there all the time since he installed RubyGems.

How about "ls -l .bashrc" to see when it was last changed? (Not valid if  
he's been editing it manually of course)

Now, if he had installed RubyGems via the system's package management  
system, then I agree it could have touched /etc/bashrc but would be very  
unlikely to touch ~/.bashrc in everyone's home directory.

Check in /etc/skel/.bashrc to see if this has been set as a global  
default for new accounts?

If a nefarious gem is suspected of making this change, then he can  
probably find it using a variant of

&nbsp;&nbsp;&nbsp;&nbsp;grep -R bashrc /usr/lib/ruby/gems/1.8

assuming it's still installed. However I hope that a gem author would  
not do something so obviously dangerous and tied to a specific  
architecture.

Regards,

Brian.

> **···**
>
> > On Mon, May 11, 2009 at 11:21 AM, Brian Candler \<b.candler@pobox.com\> \> wrote:
> 
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [10 May 2009 09:10 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/9 "2009-05-10T09:10:02Z")

</div>

I guess it is really time for me to learn about Rubygems I was  
convinced that gem install can run post install hooks which could do  
about anything in the system.  
If you have a safety net about this, well I'am impressed.  
Cheers  
Robert

> **···**
>
> On Sat, May 9, 2009 at 11:41 PM, Eric Hodel \<drbrain@segment7.net\> wrote:
> 
> > On May 9, 2009, at 01:13, Robert Dober wrote:
> > 
> > > On Fri, May 8, 2009 at 7:24 PM, Eric Hodel \<drbrain@segment7.net\> wrote:
> > > 
> > > > On May 7, 2009, at 1:08, Albert Schlef \<albertschlef@gmail.com\> wrote:
> > > > 
> > > > > I've just found the following line in my ~/.bashrc:
> > > > > 
> > > > > PATH=$PATH:~/.gem/ruby/1.8/bin
> > > > > 
> > > > > Now, that's vey beautiful. Instead of cluttering /usr/bin, everythig  
> > > > > goes in ~/.gem/ruby/1.8/bin.
> > > > > 
> > > > > But I wonder. Who added this line to my ~/.bashrc? I doubt it's me,  
> > > > > because, IIRC, just today I discovered the fact the RubyGems puts  
> > > > > binaries  
> > > > > there.
> > > > 
> > > > It wasn't RubyGems, however RubyGems does warn you if you have  
> > > > --user-install (current default) and don't have the user bin for in your  
> > > > PATH.
> > > 
> > > Eric I did not think of RubyGems, but rather of the gem itself. Do you  
> > > think this is possible?
> > 
> > It's possible, but it wouldn't happen at install time.
> 
> --  
> Si tu veux construire un bateau ...  
> Ne rassemble pas des hommes pour aller chercher du bois, préparer des  
> outils, répartir les tâches, alléger le travail… mais enseigne aux  
> gens la nostalgie de l’infini de la mer.
> 
> If you want to build a ship, don’t herd people together to collect  
> wood and don’t assign them tasks and work, but rather teach them to  
> long for the endless immensity of the sea.
> 
> --  
> Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![Albert\_Schlef](https://avatars.discourse-cdn.com/v4/letter/a/839c29/32.png) [@Albert\_Schlef](https://rubytalk.org/u/Albert_Schlef)\
**Post date:** [11 May 2009 10:11 UTC](https://rubytalk.org/t/who-added-this-to-my-path/53274/10 "2009-05-11T10:11:44Z")

</div>

Hi, I'm the original poster.

> I hope that a gem author would  
> not do something so obviously dangerous

After thinking more about this, I think there's 70% probablity that it  
was I who added that line to that file. It's just that I don't remember  
this. I do remember that I was writing a certain gem that had an  
executable I experimented with. So let's make it a 85% probability.

And since it's hard to believe any alien script would add that line,  
we'll have to conclude that it is indeed my own handiwork.

> How about "ls -l .bashrc" to see when it was last changed?

I tried that, but I might have edited that file since.

I'd better put all my config file in a git repository.

> If a nefarious gem is suspected of making this change, then he can  
> probably find it using a variant of
> 
> &nbsp;&nbsp;&nbsp;&nbsp;grep -R bashrc /usr/lib/ruby/gems/1.8

(I cleaned up my system, so many of the gems I had aren't there  
anymore.)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).
