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

Do not force PATH in the installer #1359

Closed
wants to merge 1 commit into from
Closed

Conversation

mpapis
Copy link

@mpapis mpapis commented Oct 15, 2012

The installer forced PATH - this prevents PATH dynamically set by system, also forces any temporary user PATH that was set during installation to be recorded and used on every shell start.

It should be users conscious choice to manipulate PATH, a lot of users is not aware of this and do not even know if this good or not.

If users need to add something to PATH they should do it by adding it not overwriting system detected PATH:

PATH="$PATH:/user/custom/path"

or:

path+=( "/user/custom/path" )

The installer forced PATH - this prevents PATH dynamically set by system, also forces any temporary user PATH that was set during installation to be recorded and used on every shell start.

It should be users conscious choice to manipulate PATH, a lot of users is not aware of this and do not even know if this good or not.

If users need to add something to PATH they should do it by adding it not overwriting system detected PATH:

    PATH="$PATH:/user/custom/path"

or:

    path+=( "/user/custom/path" )
@robbyrussell
Copy link
Member

@mpapis I've not heard many people complain about this. The purpose behind retaining what was currently in the $PATH is that we're trying to avoid people having shit break when they're installing OhMyZsh for the first time (as we're assuming you're someone who is working with bash... and if you lose your PATH and/or aren't that shell savvy, you'll be confused why things aren't working)

Someone with more know can still modify this after-the-fact, no?

@robbyrussell
Copy link
Member

Happy to discuss this further, but am not convinced yet (as we're assuming a PATH was already defined to their liking and we're just retaining that)

@mpapis
Copy link
Author

mpapis commented Dec 1, 2012

@robbyrussell it works as long you have static environment, but for dynamic environment's it's a headache, you predefine the PATH with something that was already loaded, like selecting environment for some tools like RVM - the selected environment is recorded this way and forced only partially on user without his knowledge why his tools fail, in case of RVM that would be recorded PATH without recording GEM_PATH - they have to be set together for proper effect. I hit this issue about two times a week it's confusing as the tool is on PATH but it can not be properly initialized because of the missing GEM_PATH.

Does this forcing PATH give you any advantage - I do not understand how hardcoding PATH would help anyone, if the PATH is "broken" during installation - you would record the broken PATH.

Finally a script installed in /etc/profile.d/*.sh is allowed to change the PATH - some systems load it for both ZSH and BASH, and you just broke it because you overwrite the dynamically calculated PATH given by system.

@mpapis
Copy link
Author

mpapis commented Dec 1, 2012

one more, the users that have issues with it explain it:

it was there - there has to be some reason why it was there, I will not remove it because something can break

I need to explain it to every of them from scratch ... at least now I can point them to this ticket

@mpapis
Copy link
Author

mpapis commented Dec 3, 2012

@robbyrussell so the issue rvm/rvm#1351 is a real life example of the problem caused by forcing PATH - please reconsider fixing this

@mpapis
Copy link
Author

mpapis commented Dec 9, 2012

@robbyrussell ping - so this does not get lost in history

@mpapis
Copy link
Author

mpapis commented Feb 8, 2013

following @postmodern advice posting steps to reproduce the problem:

$ rvm use 1.9.3 --default
$ rvm use 1.8.7
$ curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

open new terminal:

$ echo $PATH
/path/to/ruby-1.8.7/bin:...
$ echo $GEM_PATH
/path/to/ruby-1.9.3:...

as you can see they are inconsistent because the PATH was recorded and dynamic checking did not work

so after installing OH-MY-ZSH it is hard coded and no other tool can add itself to the PATH.

@mpapis
Copy link
Author

mpapis commented Apr 6, 2013

a regular reminder to reopen this - just had another user with the same problem, removing the hard coded PATH fixes it always, we even had to implement a warning for it because this problem was so often - https://github.com/wayneeseguin/rvm/blob/master/scripts/notes#L160-L183

@carllerche
Copy link

I've hit this issue as well. So has @wycats.

@wycats
Copy link

wycats commented Apr 9, 2013

Confirm. I'm surprised you don't consider this a serious issue. It's driving me crazy 😦

I have added rvm reload to my .zshrc 😦

@christophrumpel
Copy link

I am facing the same issue here =(

@rattlion
Copy link

+1

@mhumeSF
Copy link

mhumeSF commented May 5, 2013

This breaks my rvm as well. Removing hard-coded $PATH from PATH=... fixed things.

@Drewch
Copy link

Drewch commented May 7, 2013

I've had this problem as well, each Ubuntu server I spin up and install rvm on I have to change the PATH=/my/path/here/by/default
to:
PATH=$PATH:/my/path/here/by/default

Note that:

PATH=/my/path/here/by/default:$PATH

will NOT fix the issue, it must be the former.

Here is my path after both settings:

https://gist.github.com/Drewch/5534745

@avit
Copy link
Contributor

avit commented Mar 8, 2014

@robbyrussell I'm thinking to submit a patch for this that will grep the user's existing ~/.bashrc ~/.profile and grab any PATH entries from there instead of the heavy-handed literal expansion we're doing here.

@drewhammond
Copy link

Ran into this problem as well on an RVM installation on OS X mavericks

@abotalov
Copy link

+1

@mcornella
Copy link
Member

Please see pull request #2589 and see if it works for you.

@connor11528
Copy link

I'm getting this error on a fresh os x mavericks running oh-my-zsh:

Upgrade Notes:

/Users/connorleech/.zshrc:54:export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"

  * WARNING: Above files contains `PATH=` with no `$PATH` inside, this can break RVM,
    for details check https://github.com/wayneeseguin/rvm/issues/1351#issuecomment-10939525
    to avoid this warning append #PATH.

What do I have to change in what file? I don't want my rvm breaking

@avit
Copy link
Contributor

avit commented Jul 16, 2014

@jasonshark In your case it looks like you can just remove that line 54 from your .zshrc. None of the paths in that error message are custom additions, so it's basically just doing the expansion of PATH="$PATH" unnecessarily.

(There's also a proposed patch to the oh-my-zsh installer in #2589 if you want to test that branch for us.)

@connor11528
Copy link

ok cool. commented out line 54 in ~/.zshrc and warning disappeared. Thank you!

@LandonSchropp
Copy link

I commented on this over at #2589 and was pointed here. I don't understand @robbyrussell's reasons for not setting the path dynamically. I spent a couple hours trying to figure out what was wrong with my rbenv install before I stumbled onto this. As @mpapis said, for those of us with dynamic environments this is a huge pain.

It seems wrong to comment out the path in the .zshrc file. That code belongs to Oh My ZSH, and by changing it I'm taking ownership of it. I'd prefer to keep all of my zsh config in the custom directory where it belongs. I wouldn't be so opposed to hardcoding $PATH if it were set in the .zshrc file before the custom config were loaded, because then I'd at least be able to add to it.

@robbyrussell, can you please elaborate a little more on why you won't consider this approach? Thanks in advance!

@jessiahr
Copy link

Looks like I am running into this issue while using RVM. Any update on a fix?

@coding-bunny
Copy link

Seeing as this is not getting fixed, uninstall oh-my-zsh till it actually works....

@apjanke
Copy link
Contributor

apjanke commented Oct 19, 2015

You don't need to uninstall Oh My Zsh. Just correct the $PATH in your ~/.zshrc, possibly by just moving your old ~/.zshrc back and copying the OMZ initialization code to it. This change only happens at installation time, and OMZ is fine running with a dynamically-set $PATH.

You can also avoid the problem by doing a manual installation by cloning the OMZ repo to ~/.oh-my-zsh and adding export ZSH=~/.oh-my-zsh; source$ZSH/.oh-my-zsh/oh-my-zsh.shto your existing~/.zshrc`.

@coding-bunny
Copy link

yea, or the project could you know....be fixed and support everything as it should be.

@jairojunior
Copy link

+1

@yucombinator
Copy link

This just fixed my rails after hours of digging. +1

@gtmax
Copy link

gtmax commented Mar 25, 2016

+1.

@mcornella mcornella reopened this Mar 31, 2016
@mcornella mcornella added Bug Something isn't working Area: installer Issue or PR related to the installer labels Mar 31, 2016
@mpapis
Copy link
Author

mpapis commented Apr 1, 2016

should I rebase?

@mcornella
Copy link
Member

No need, sorry, I just reopened this again to signal that it's not solved yet.

@diegomelo182
Copy link

+1

1 similar comment
@lasernite
Copy link

+1

@milos-v
Copy link

milos-v commented Jun 7, 2016

This one did it for me
stackoverflow

@apjanke
Copy link
Contributor

apjanke commented Jun 8, 2016

This one did it for me

/etc/paths is a system-level configuration file. OMZ is more of a user-level shell customization framework; it probably shouldn't be modifying /etc/paths, or doing anything that requires modification of it.

@milos-v
Copy link

milos-v commented Jun 12, 2016

Well OMZ is not changing it. I changed the order of paths in the file like it says here:

open your /etc/paths file, put /usr/local/bin on top of /usr/bin

Not sure how it relates to the issue honestly but the issue is gone.

@apjanke
Copy link
Contributor

apjanke commented Jun 12, 2016

@milos-v Right. I'm saying you shouldn't have had to do that in the first place. And also that, even if that act worked for you, OMZ shouldn't do the same thing.

But moreover, the problem in this issue report occurs when you:
a) run the OMZ installer, and then later:
b) do something that changes /etc/paths.d
or
c) share your ~/.zshrc between machines with differing /etc/paths.d states
If you didn't do these two things, you're probably not looking at quite the same issue as this bug report.

@cristophergalarce
Copy link

Works for me. Thanks

@hayesmaker
Copy link

+1

@j3rrey
Copy link

j3rrey commented Sep 21, 2016

+1 found this as a workaround https://github.com/postmodern/chruby

@CodyLeeWhite
Copy link

This problem is to much trouble. uninstalling as it appears a fix will not be made. I should not have to manually edit ohmyzsh to get my path to work with it.

@dehengxu
Copy link

You should comment the rvm related lines in ~/.zshrc, it works for me.

@mcornella
Copy link
Member

This was fixed in #4925. I don't know why I kept it open so long.

@mcornella mcornella closed this Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: installer Issue or PR related to the installer Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet