Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

zsh: support site specific files #11936

Merged
merged 0 commits into from

4 participants

@docwhat

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.

@docwhat

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

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:

@jacknagel
Collaborator

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

@docwhat
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.

@jacknagel Collaborator

Preferred Homebrew style is

(HOMEBREW_PREFIX/'share/zsh/site-functions').mkpath
@docwhat
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
@docwhat docwhat merged commit b70b69c into Homebrew:master
@docwhat

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

@docwhat

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

@docwhat

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.

@docwhat

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

@mikemcquaid
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.

@docwhat

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

@mikemcquaid
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.

@docwhat

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 docwhat referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@docwhat docwhat referenced this pull request from a commit in docwhat/homebrew
@docwhat 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
@jacknagel jacknagel referenced this pull request from a commit
@docwhat 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
@jacknagel jacknagel referenced this pull request from a commit
@docwhat 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
@jacknagel jacknagel referenced this pull request from a commit
@docwhat 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
@docwhat docwhat referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@rohansingh rohansingh referenced this pull request from a commit in rohansingh/homebrew
@docwhat 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
@rohansingh rohansingh referenced this pull request from a commit in rohansingh/homebrew
@docwhat 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
@rohansingh rohansingh referenced this pull request from a commit in rohansingh/homebrew
@docwhat 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
@zhangcheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@zhangcheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@zhangcheng zhangcheng referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@Sharpie Sharpie referenced this pull request from a commit in Sharpie/homebrew
@docwhat 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
@Sharpie Sharpie referenced this pull request from a commit in Sharpie/homebrew
@docwhat 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
@Sharpie Sharpie referenced this pull request from a commit in Sharpie/homebrew
@docwhat 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
@docwhat 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
@docwhat 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
@docwhat 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
This page is out of date. Refresh to see the latest.
Showing with 0 additions and 0 deletions.
Something went wrong with that request. Please try again.