This repository has been archived by the owner. It is now read-only.

zsh: support site specific files #11936

Merged
merged 0 commits into from Apr 30, 2012

Conversation

Projects
None yet
4 participants
Contributor

docwhat commented Apr 29, 2012

This fixes the site-scripts and site-functions directories
so that zsh points to the HOMEBREW_PREFIX version of these files
instead of the Cellar version.

This means you can drop files in these directories and the files
will persist when you upgrade zsh. Otherwise they disappear when
you upgrade zsh.

Contributor

docwhat commented Apr 29, 2012

Some more info about this.

At the moment, the default value of $fpath is /usr/local/Cellar/zsh/4.3.17/share/zsh/site-functions /usr/local/Cellar/zsh/4.3.17/share/zsh/functions

But formulas for some things like ack, hub, task, etc. all put their files in /usr/local/share/zsh/functions but they won't be picked up automatically.

If you add /usr/local/share/zsh/functions to your $fpath in your .zshrc, then you get doubled functions and there are a lot of functions there. This slows zsh startup time. Even worse, it can break /bin/zsh or cause it to behave weird because it'll use the wrong functions directory!

docwhat added a commit to docwhat/homebrew that referenced this pull request Apr 29, 2012

git-now: install completion into site-functions
`_git-now` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

docwhat added a commit to docwhat/homebrew that referenced this pull request Apr 29, 2012

git-flow: install completion into site-functions
`_git-flow` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.
Contributor

docwhat commented Apr 29, 2012

I didn't realize adding the issue number to the commits add them to the this as well... I'm sorry if that was wrong to do. :-/

List of related commits:

Contributor

jacknagel commented Apr 29, 2012

@sorin-ionescu can you comment on this?

Contributor

sorin-ionescu commented Apr 29, 2012

Merge it. The site directories are meant for other packages to install Zsh files.

This is a workaround for a larger Homebrew problem shared with many other packages. Homebrew should build packages prefixed into HOMEBREW_PREFIX but installed in Cellar and symbolically linked in HOMEBREW_PREFIX. In order to do this right, it would probably have to depend on fakeroot.

Library/Formula/zsh.rb
+ # These are site-specific (non-version dependant) file locations.
+ # They shouldn't be symlinks to the Cellar or else a user cannot
+ # override the contents.
+ system "mkdir -p #{HOMEBREW_PREFIX}/share/zsh/site-functions"
@sorin-ionescu

sorin-ionescu Apr 29, 2012

Contributor

Is this necessary? Also, you can use Dir.mkdir. These are Ruby files after all.

@docwhat

docwhat Apr 29, 2012

Contributor

smacks forehead D'oh! I was in "package developer" mode and completely forgot what I was writing.

I have lots of experience writing RPMs (I was the Sr. Build Engineer for TurboLinux (RIP)) and I've packaged for Debian and things like the Zaurus project, etc. My "package" habits just took over.

I'll fix it now.

@jacknagel

jacknagel Apr 29, 2012

Contributor

Preferred Homebrew style is

(HOMEBREW_PREFIX/'share/zsh/site-functions').mkpath
@docwhat

docwhat Apr 30, 2012

Contributor

Thanks, I was looking for the function that doesn't get grumpy when the path already exists.

@docwhat docwhat merged commit b70b69c into Homebrew:master Apr 30, 2012

Contributor

docwhat commented Apr 30, 2012

Sorry, I didn't meant to close this. I submitted a new pull request as #11955.

Contributor

docwhat commented Apr 30, 2012

@sorin-ionescu Can you explain why you think you need fakeroot when you don't right now?

I've used stow, which is sort of like the linker part of homebrew, for many years and I use the above strategy for the majority of packages I've installed via stow. Some packages are just badly formed and can't have prefix overridden on install (or if they do, they cause the package to recompile cough_git_cough). But a lot of them work fine. I have a pull request that does exactly that for vim in homedir-dupes right now.

I didn't do it for zsh because it has really nice configure options that let you do it via configure instead of mucking about with figuring out the way to override prefix on install.

Ciao!

Contributor

sorin-ionescu commented Apr 30, 2012

You can't make install into HOMEBREW_PREFIX and expect to put it into Cellar aftewards. fakeroots helps you with fake paths.

You don't have to create new pull requests. You can reopen closed ones.

Contributor

docwhat commented Apr 30, 2012

Ah. I see. My usual pattern for well behaved autotools build packages is:

# Translating into homebrewlish.

./configure --prefix=#{HOMEBREW_PREFIX}
make
make install prefix=#{prefix}

This works for well behaved software, but not all.

re: pull request. There was no button... hmm.. Maybe I just push into again and it reopens? I didn't try that.

Contributor

sorin-ionescu commented Apr 30, 2012

How do you intend to uninstall that? If did --prefix=#{HOMEBREW_PREFIX}/Cellar/foo/bar instead, you could brew remove foo later.

Contributor

docwhat commented Apr 30, 2012

@sorin-ionescu I'm unclear what you mean? The install goes into the Cellar (because #{prefix} is the Cellar path, right?). It is symlinked by the brew link phase as normal. All that is different is the paths compiled into the software is pointing at HOMEBREW_PREFIX instead of prefix.

Did I misunderstand something?

BTW: I'm docwhat on freenode IRC, feel free to say hi there.

Ciao!

Owner

MikeMcQuaid commented Apr 30, 2012

I'm using /bin/zsh and that functions directory and it seems to work fine for me. Can you provide a test case indicating the breakage? What we could do about it is instead point the zsh formula to the current location. I'm open to being educated if I'm wrong here though; I'm just concerned about breaking peoples' currently working (if problematic) setups.

Contributor

docwhat commented Apr 30, 2012

@MikeMcQuaid:

Scenario 1:

  • You have homebrew zsh installed. It is in new enough that the built-in functions use new zsh features.
  • Your ~/.zshrc has added /usr/local/share/zsh/functions to your $fpath.
  • If you run /bin/zsh it'll behave incorrectly or emit errors/warnings due to the new style functions.

Scenario 2:

  • If you have homebrew zsh.
  • If you install homebrew ack.
  • Your .zshrc does not have /usr/local/share/zsh/functions in the $fpath.
  • You will not get the ack completion function: _ack (see issue #11937).

Scenario 3:

  • You install homebrew zsh.
  • You add /usr/local/share/zsh/functions to your $fpath in your ~/.zshrc
  • Now zsh uses more memory and is slower because it has twice as many functions loaded. That is partially how I noticed this in the first place. My Mac has been running out of sysctl kern.maxvnodes and zsh was taking forever to start because it scans the $path and $fpath.

Scenario 4:

  • homebrew zsh is installed.
  • multiple people use the same computer.
  • The file important-file is added into /usr/local/share/zsh/site-functions or site-scripts
  • homebrew zsh is upgraded
  • important-file is now gone, because the site-functions and site-scripts links are now pointing at the new version of zsh in the Cellar.

I can probably go on... but long and short is it means homebrew zsh doesn't follow the principal of least surprise -- it behaves differently than the official zsh documentation implies.

Ideally, I think we should remove linking the share/zsh/functions when installing zsh, but I'm unsure if/how that can be done.

I'm unclear about what you meant about "point the zsh formula to the current location"?

Ciao!

Owner

MikeMcQuaid commented May 1, 2012

Ok, this makes a bit more sense now, thanks. I guess we'll just do it and hope people notice or have a caveat or something.

Contributor

docwhat commented May 1, 2012

For all the packages that installed files into share/zsh/functions I have updated their caveats (or added ones) to tell them its now site-functions. Hopefully that'll mitigate any pain.

docwhat added a commit to docwhat/homebrew that referenced this pull request May 2, 2012

autojump: install completion into site-functions
`_autojump` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

jacknagel added a commit that referenced this pull request May 3, 2012

git-now: install completion into site-functions
`_git-now` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11940.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

jacknagel added a commit that referenced this pull request May 3, 2012

git-flow: install completion into site-functions
`_git-flow` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11941.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

jacknagel added a commit that referenced this pull request May 3, 2012

autojump: install completion into site-functions
`_autojump` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11942.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

rohansingh added a commit to rohansingh/homebrew that referenced this pull request May 7, 2012

git-now: install completion into site-functions
`_git-now` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11940.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

rohansingh added a commit to rohansingh/homebrew that referenced this pull request May 7, 2012

git-flow: install completion into site-functions
`_git-flow` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11941.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

rohansingh added a commit to rohansingh/homebrew that referenced this pull request May 7, 2012

autojump: install completion into site-functions
`_autojump` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11942.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

Sharpie pushed a commit to Sharpie/homebrew that referenced this pull request Sep 12, 2012

git-now: install completion into site-functions
`_git-now` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11940.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

Sharpie pushed a commit to Sharpie/homebrew that referenced this pull request Sep 12, 2012

git-flow: install completion into site-functions
`_git-flow` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11941.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

Sharpie pushed a commit to Sharpie/homebrew that referenced this pull request Sep 12, 2012

autojump: install completion into site-functions
`_autojump` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11942.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this pull request Dec 17, 2012

git-now: install completion into site-functions
`_git-now` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11940.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this pull request Dec 17, 2012

git-flow: install completion into site-functions
`_git-flow` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11941.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this pull request Dec 17, 2012

autojump: install completion into site-functions
`_autojump` needs to be installed into `share/zsh/site-functions`
not `share/zsh/functions`.

Files in `share/zsh/functions` must not change unless zsh is
upgraded and zsh is restarted.  `site-functions` can change during a zsh
process's lifetime.

This will enable homebrew's zsh to automatically use the completion.
See issue #11936 for details.

Closes #11942.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>

@xu-cheng xu-cheng locked and limited conversation to collaborators Feb 16, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.