Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$PATH is getting sorted #5

Open
AJ-Acevedo opened this issue Dec 29, 2014 · 8 comments
Open

$PATH is getting sorted #5

AJ-Acevedo opened this issue Dec 29, 2014 · 8 comments
Labels

Comments

@AJ-Acevedo
Copy link
Owner

@Bwoe @tigfox

In an attempt to remove duplicates from my $PATH I now have a strange behavior. Need some awk help here.

If you source the .bashrc file the $PATH appears in the correct order. But when you quit and open the Terminal, the $PATH is getting sorted.

Introduced here
https://github.com/AJ-Acevedo/dotfiles/blob/master/bashrc#L91

@AJ-Acevedo AJ-Acevedo added the bug label Dec 29, 2014
@tigfox
Copy link

tigfox commented Dec 29, 2014

Don’t you have to work in the morning? 2:30 is way too late to be working on dotfiles.
Can you echo your path for me so I can step through what awk is up to?
What do you mean “the $PATH is getting sorted”? Sorted how?

On Dec 29, 2014, at 2:34 AM, AJ [email protected] wrote:

@Bwoe @tigfox

In an attempt to remove duplicates from my $PATH I now have a strange behavior. Need some awk help here.

If you source the .bashrc file the $PATH appears in the correct order. But when you quit and open the Terminal, the $PATH is getting sorted.

Introduced here
https://github.com/AJ-Acevedo/dotfiles/blob/master/bashrc#L91


Reply to this email directly or view it on GitHub.

@AJ-Acevedo
Copy link
Owner Author

I'm off until Wednesday. :)

Here is what is happening. When I say that it is getting sorted after quitting Terminal this is the output of echo $PATH

/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin

Once I source .bashrc this is the output of echo $PATH

/usr/local/bin:/usr/local/sbin:/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin

As you can see once I source the .bashrc file brew's path is back in the front where is supposed to be as per line 82

Thank bro!
AJ

@AJ-Acevedo
Copy link
Owner Author

Without line 91, the PATH is duplicated every time I source .bashrc.

Here is my PATH after sourcing .bashrc three times.

/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin

@tigfox
Copy link

tigfox commented Dec 29, 2014

  • Brian, because I’m bad at reply-all.

OK, got it. It seems that your awk line should take care of it - pulls each record (separated by “:”) into an array, then tests each consecutive one to see if it already exists in the array - if it doesn’t, it gets printed. (and then the sed to remove that trailing “:” from awk (isn’t there a way to have awk not print a last ORS?)). Makes sense.

I don’t think it’s the awk that’s breaking it. Maybe something about the difference between using “source” and starting a new shell? source is appending to the old path instead of destroying it? Because it’s running in the current (shell) process, it can’t destroy the path (which it needs to know where non-builtins live?)? Try exporting that last $PATH and see if it replaces instead of appends?

I know it’s not what you’re after, but why not hard-code your PATH?

On Dec 29, 2014, at 5:39 PM, AJ [email protected] wrote:

Without line 91, the PATH is duplicated every time I source .bashrc.

Here is my PATH after sourcing .bashrc three times.

/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin


Reply to this email directly or view it on GitHub.

@tigfox
Copy link

tigfox commented Dec 29, 2014

Also, I’m “working from home” most of this week (except tomorrow), as the office will be dead. We should do something.

On Dec 29, 2014, at 6:29 PM, Eric Franson [email protected] wrote:

  • Brian, because I’m bad at reply-all.

OK, got it. It seems that your awk line should take care of it - pulls each record (separated by “:”) into an array, then tests each consecutive one to see if it already exists in the array - if it doesn’t, it gets printed. (and then the sed to remove that trailing “:” from awk (isn’t there a way to have awk not print a last ORS?)). Makes sense.

I don’t think it’s the awk that’s breaking it. Maybe something about the difference between using “source” and starting a new shell? source is appending to the old path instead of destroying it? Because it’s running in the current (shell) process, it can’t destroy the path (which it needs to know where non-builtins live?)? Try exporting that last $PATH and see if it replaces instead of appends?

I know it’s not what you’re after, but why not hard-code your PATH?

On Dec 29, 2014, at 5:39 PM, AJ [email protected] wrote:

Without line 91, the PATH is duplicated every time I source .bashrc.

Here is my PATH after sourcing .bashrc three times.

/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin


Reply to this email directly or view it on GitHub.

@Bwoe
Copy link
Contributor

Bwoe commented Dec 30, 2014

I'm not at a computer so forgive the mind-barf. The .bashrc I've got from your dotfiles is a symlink to another location. Logically it should be the same result as an actual file in that spot, but for testing can you make an actual ~/.bashrc with the current syntax? Also, do the various path-producing files (.bashrc, .profile, etc.) get sourced in a particular order? Perhaps another file is causing conflict?

On Dec 29, 2014, at 6:32 PM, tigfox [email protected] wrote:

Also, I’m “working from home” most of this week (except tomorrow), as the office will be dead. We should do something.

On Dec 29, 2014, at 6:29 PM, Eric Franson [email protected] wrote:

  • Brian, because I’m bad at reply-all.

OK, got it. It seems that your awk line should take care of it - pulls each record (separated by “:”) into an array, then tests each consecutive one to see if it already exists in the array - if it doesn’t, it gets printed. (and then the sed to remove that trailing “:” from awk (isn’t there a way to have awk not print a last ORS?)). Makes sense.

I don’t think it’s the awk that’s breaking it. Maybe something about the difference between using “source” and starting a new shell? source is appending to the old path instead of destroying it? Because it’s running in the current (shell) process, it can’t destroy the path (which it needs to know where non-builtins live?)? Try exporting that last $PATH and see if it replaces instead of appends?

I know it’s not what you’re after, but why not hard-code your PATH?

On Dec 29, 2014, at 5:39 PM, AJ [email protected] wrote:

Without line 91, the PATH is duplicated every time I source .bashrc.

Here is my PATH after sourcing .bashrc three times.

/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/aj/.rvm/gems/ruby-2.1.2/bin:/Users/aj/.rvm/gems/ruby-2.1.2@global/bin:/Users/aj/.rvm/rubies/ruby-2.1.2/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin:/Users/aj/bin:/Users/aj/.rvm/bin


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

@AJ-Acevedo
Copy link
Owner Author

@Bwoe The .dotfiles/bashrc file can be manually moved to ~/.bashrc and it will work just fine. The only reason I symlink it to the .dotfiles directory is so i can easily version control all of my dotfiles with git.

@tigfox I am able to fix the issue for Mac OS (see screen shot) but the issue persists on Linux.
cli

@tigfox
Copy link

tigfox commented Dec 30, 2014

so make that the last line in your .bashrc? Fuck, that feels like inception.

Tomorrow, after fewer drinks.

On Dec 29, 2014, at 8:59 PM, AJ [email protected] wrote:

@Bwoe The .dotfiles/bashrc file can be manually moved to ~/.bashrc and it will work just fine. The only reason I symlink it to the .dotfiles directory is so i can easily version control all of my dotfiles with git.

@tigfox I am able to fix the issue for Mac OS (see screen shot) but the issue persists on Linux.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants