Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

zsh: support site specific files #11936

Merged
merged 0 commits into from

4 participants

Christian Höltje Jack Nagel Sorin Ionescu Mike McQuaid
Christian Höltje

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.

Christian Höltje

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!

Christian Höltje docwhat referenced this pull request from a commit in docwhat/homebrew
Christian Höltje docwhat 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.
cf3b29f
Christian Höltje docwhat referenced this pull request from a commit in docwhat/homebrew
Christian Höltje docwhat 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.
a48d8fd
Christian Höltje docwhat referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Christian Höltje

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:

Jack Nagel
Owner

@sorin-ionescu can you comment on this?

Sorin Ionescu

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
@@ -38,6 +38,12 @@ def install
"$(libdir)/$(tzsh)/$(VERSION)", "$(libdir)"
system "make install"
+
+ # 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"

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

Christian Höltje
docwhat added a note

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.

Jack Nagel Owner

Preferred Homebrew style is

(HOMEBREW_PREFIX/'share/zsh/site-functions').mkpath
Christian Höltje
docwhat added a note

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Christian Höltje docwhat merged commit b70b69c into from
Christian Höltje

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

Christian Höltje

@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 coughgitcough). 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!

Sorin Ionescu

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.

Christian Höltje

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.

Sorin Ionescu

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

Christian Höltje

@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!

Mike McQuaid
Owner

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.

Christian Höltje

@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!

Mike McQuaid
Owner

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.

Christian Höltje

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.

Christian Höltje docwhat referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Christian Höltje docwhat referenced this pull request from a commit in docwhat/homebrew
Christian Höltje docwhat 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.
574469b
Jack Nagel jacknagel referenced this pull request from a commit
Christian Höltje docwhat 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>
7be0790
Jack Nagel jacknagel referenced this pull request from a commit
Christian Höltje docwhat 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>
f69cfc6
Jack Nagel jacknagel referenced this pull request from a commit
Christian Höltje docwhat 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>
5bf4744
Christian Höltje docwhat referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Rohan Singh rohansingh referenced this pull request from a commit in rohansingh/homebrew
Christian Höltje docwhat 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>
b1124a7
Rohan Singh rohansingh referenced this pull request from a commit in rohansingh/homebrew
Christian Höltje docwhat 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>
f1352b5
Rohan Singh rohansingh referenced this pull request from a commit in rohansingh/homebrew
Christian Höltje docwhat 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>
e8917d0
ZHANG Cheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
ZHANG Cheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
ZHANG Cheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Charlie Sharpsteen Sharpie referenced this pull request from a commit in Sharpie/homebrew
Christian Höltje docwhat 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>
0cd7f7d
Charlie Sharpsteen Sharpie referenced this pull request from a commit in Sharpie/homebrew
Christian Höltje docwhat 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>
71370d4
Charlie Sharpsteen Sharpie referenced this pull request from a commit in Sharpie/homebrew
Christian Höltje docwhat 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>
4167220
snakeyroc3 snakeyroc3 referenced this pull request from a commit in snakeyroc3/homebrew
Christian Höltje docwhat 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>
4a901fd
snakeyroc3 snakeyroc3 referenced this pull request from a commit in snakeyroc3/homebrew
Christian Höltje docwhat 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>
4759862
snakeyroc3 snakeyroc3 referenced this pull request from a commit in snakeyroc3/homebrew
Christian Höltje docwhat 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>
4276f70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Sorry, commit information is not available for this pull request.

Something went wrong with that request. Please try again.