FS#35966 - [zsh] Package /etc/profile sourcing in zshenv, not zprofile

Attached to Project: Arch Linux
Opened by patrick (brisbin33) - Friday, 28 June 2013, 17:57 GMT
Last edited by Pierre Schmitz (Pierre) - Sunday, 17 November 2013, 10:53 GMT
Task Type Feature Request
Category Packages
Status Closed
Assigned To Pierre Schmitz (Pierre)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 6
Private No

Details

Problem:

The zsh package ships with an /etc/zsh/zprofile which sources /etc/profile.

Request:

Arch should package that content in /etc/zsh/zshenv, not /etc/zsh/zprofile.

Details:

/etc/zsh/zprofile is sourced *after* ~/.zshenv, overriding any $PATH set there.

The Wiki notes this, telling users to modify the shipped zprofile or set their $PATH in ~/.zshrc.

Modifying /etc/zsh/zprofile to not source /etc/profile breaks many things unless you know when and how to source /etc/profile yourself.

Setting your $PATH in ~/.zshrc is sub-optimal b/c then that $PATH is only available in interactive shells.

On my systems, I simply mv /etc/zsh/zprofile to /etc/zsh/zshenv.

I've been doing this for a while without breakage. However, any zsh updates put /etc/zsh/zprofile back and break my $PATH until I realize what happened and remove it again.
This task depends upon

Closed by  Pierre Schmitz (Pierre)
Sunday, 17 November 2013, 10:53 GMT
Reason for closing:  Not a bug
Comment by patrick (brisbin33) - Wednesday, 23 October 2013, 19:48 GMT
This bit me again today. Any thoughts, concerns?

Here's an updated PKGBUILD, if that's useful. The zprofile source should probably be renamed though.

# $Id: PKGBUILD 187080 2013-06-03 11:17:13Z allan $
# Maintainer: Pierre Schmitz <pierre@archlinux.de>

pkgname=zsh
pkgver=5.0.2
pkgrel=3
pkgdesc='A very advanced and programmable command interpreter (shell) for UNIX'
arch=('i686' 'x86_64')
url='http://www.zsh.org/'
license=('custom')
depends=('pcre' 'libcap' 'gdbm')
backup=('etc/zsh/zshenv')
install=zsh.install
source=("http://downloads.sourceforge.net/${pkgname}/${pkgname}-${pkgver}.tar.bz2"
'zprofile')
md5sums=('b8f2ad691acf58b3252225746480dcad'
'24a9335edf77252a7b5f52e079f7aef7')

build() {
cd "${srcdir}/${pkgname}-${pkgver}"

# Set correct keymap path
sed -i 's#/usr/share/keymaps#/usr/share/kbd/keymaps#g' Completion/Unix/Command/_loadkeys

# Remove unneeded and conflicting completion scripts
rm -rf Completion/{AIX,BSD,Cygwin,Darwin,Debian,Mandriva,openSUSE,Redhat,Solaris}
rm -f Completion/Linux/Command/_{pkgtool,rpmbuild,yast}
rm -f Completion/Unix/Command/_osc

./configure --prefix=/usr \
--enable-etcdir=/etc/zsh \
--enable-zshenv=/etc/zsh/zshenv \
--enable-zlogin=/etc/zsh/zlogin \
--enable-zlogout=/etc/zsh/zlogout \
--enable-zprofile=/etc/zsh/zprofile \
--enable-zshrc=/etc/zsh/zshrc \
--enable-maildir-support \
--with-term-lib='ncursesw' \
--enable-multibyte \
--enable-function-subdirs \
--enable-fndir=/usr/share/zsh/functions \
--enable-scriptdir=/usr/share/zsh/scripts \
--with-tcsetpgrp \
--enable-pcre \
--enable-cap \
--enable-zsh-secure-free
make
}

check() {
cd "${srcdir}/${pkgname}-${pkgver}"
HOME="${srcdir}" make check
}

package() {
cd "${srcdir}/${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}/" install
install -D -m644 "${srcdir}/zprofile" "${pkgdir}/etc/zsh/zshenv"
install -D -m644 LICENCE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
Comment by jason ryan (jasonwryan) - Friday, 01 November 2013, 07:12 GMT
This seems a recurring issue:
https://bugs.archlinux.org/task/24953 - June 2011
https://bugs.archlinux.org/task/31873 - October 2012

Is there some reason why we don't implement this as upstream intended? It is frustrating to have to use a work around to achieve what should be default behaviour.
Comment by Pierre Schmitz (Pierre) - Saturday, 02 November 2013, 23:40 GMT
The problem is that /etc/profile should only be sourced by login shells as its done by bash. zshenv would also be used by non-login shells.
Comment by patrick (brisbin33) - Saturday, 02 November 2013, 23:52 GMT
Hmm. I can't think of a good solution, if that's a requirement. Mr. Ryan, I'm curious, what do you gather is intended by upstream?

I'm fairly sure I need/want /etc/profile sourced, just not from zprofile. If it can't be sourced in zshenv (for bash compatibility?), I'm at a loss as to where to do it.
Comment by Pierre Schmitz (Pierre) - Saturday, 02 November 2013, 23:57 GMT
The problem is probably in /etc/profile which does more than setting PATHs. It seems other Distros like Debian or Fedora use it this way as well. I have also seen warnigs about using more complex stuff inside zshenv.
Comment by patrick (brisbin33) - Sunday, 03 November 2013, 00:06 GMT
It's the modifying of PATHs that's the exact issue though, since it occurs before ~/.zshenv where a user is meant to setup their own PATH.

Perhaps, if it's intended that PATHs be mucked with in a *profile file, then I should put my own path overrides in ~/.zprofile and not ~/.zshenv ?
Comment by Pierre Schmitz (Pierre) - Sunday, 03 November 2013, 00:19 GMT
s long as our global /etc/profile is some kind of mix between things that should go into zshenv and zprofile I suggest to set your PATH in zshrc. But still, it's not a big deal; have a look at pacman.conf's NoExtract or NoUpgrade options if you like to keep your own /etc/zprofile.
Comment by jason ryan (jasonwryan) - Wednesday, 06 November 2013, 01:59 GMT
Thanks Pierre: I've gone with noextract...
Comment by patrick (brisbin33) - Wednesday, 06 November 2013, 02:02 GMT
Yes, thanks. That sounds like the option I'll go with as well.
Comment by jason ryan (jasonwryan) - Wednesday, 06 November 2013, 03:38 GMT
A final question, if I may Pierre.

Zsh ships without an /etc/zsh/zprofile and Debian with an empty one: why do we create one rather than using the /etc/zsh/zshenv that ships from upstream (albeit with the line inserted to source /etc/profile)?

I am probably just being dense, but the solution that Patrick and I use, to copy /etc/zsh/zprofile to /etc/zsh/zshenv seems closer to upstream than the current approach. Our /etc/profile, FWIW, only differs from debian's in unsetting the man path and termcap (and sourcing bash.bashrc).

Any light you can shed on this would be helpful. Thanks.
Comment by Lucy (lucy) - Sunday, 17 November 2013, 10:29 GMT
Gentoo "resolved" this a while ago: https://bugs.gentoo.org/show_bug.cgi?id=19924#c50
Perhaps it should be taken upstream, since most systems shipping zsh have an issue with this (even OS X does).
Comment by Pierre Schmitz (Pierre) - Sunday, 17 November 2013, 10:52 GMT
@jasonwryan: if we don't ship zprofile, some PATH and vars wont get set and that will break applications. E.g. locale wont get set and Perl wont work. Upstream does not ship any default config. And to summarize: sourcing /etc/profile in zshenv is not correct and not useful.

Loading...