Skip to content

Commit

Permalink
trying to fix FPATH setting when starting with ksh or bash
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert McLay committed Jun 24, 2024
1 parent e2190e8 commit 1e8cfd4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.new
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ Lmod 8.7+
(8.7.39) * Fix busted test for ModuleA.
(8.7.40) * Bug fix for prepend/append path when trying to add an empty string.
* Bug fix for serializeTbl: handle empty or single blank string as key
W.I.P:
(8.7.41) * Issue #680: Adding new function depends_on_any()
* Issue #680: If $MODULES_AUTO_HANDLING is set then prereq() -> depends_on(); prereq_any() -> depends_on_any()
* Issue #686: Generate a perl pod format for manpage for module.1'
* ModuleTable modification: Changes to $MODULEPATH are stored in an entry.
(8.7.42) * Fix setting of $FPATH when running bash or ksh shell and executing zsh -l.


32 changes: 19 additions & 13 deletions init/bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,26 @@ fi
# Prepend the FPATH variable for ksh functions when ssh is being used,
# except for zsh as it breaks things there.

SUPPORT_KSH="@support_ksh@"
if [ $SUPPORT_KSH = yes -o -n "${KSH_VERSION+x}" ]; then
if [ -z "${__LMOD_SET_FPATH+x}" ]; then
zv=${ZSH_VERSION}
orig_zsh_version=@orig_zsh_version@
zsh_fpath=@zsh_fpath@
zsh_fpath=$(echo $zsh_fpath | sed -e "s|/$orig_zsh_version/|/$zv/|g" )
export FPATH=$(@PKGV@/libexec/addto --append FPATH $zsh_fpath @PKGV@/init/ksh_funcs)
export __LMOD_SET_FPATH=1
unset zv
unset orig_zsh_version
unset zsh_fpath
fi

if [ -n "${ZSH_VERSION+x}" -a -z "${__LMOD_SET_ZSH_FPATH+x}" ]; then

This comment has been minimized.

Copy link
@shiltian

shiltian Jul 20, 2024

It looks like this block code doesn't work very well with oh-my-zsh if the init file is sourced at .zshrc. zsh complains url-quote-magic: function definition file not found on every single key stroke.

Specifically, the code looks like this on my end:

if [ -n "${ZSH_VERSION+x}" -a -z "${__LMOD_SET_ZSH_FPATH+x}" ]; then
  export __LMOD_SET_ZSH_FPATH=1
  zv=${ZSH_VERSION}
  orig_zsh_version=
  zsh_fpath=
  zsh_fpath=$(echo $zsh_fpath | sed -e "s|/$orig_zsh_version/|/$zv/|g" )
  export FPATH=$(/home/linuxbrew/.linuxbrew/Cellar/lmod/8.7.45/libexec/addto --append FPATH $zsh_fpath /home/linuxbrew/.linuxbrew/Cellar/lmod/8.7.45/init/ksh_funcs)
  unset zv
  unset orig_zsh_version
  unset zsh_fpath
fi

I installed Lmod via HomeBrew. The two empty variables might be the culprit.

This comment has been minimized.

Copy link
@rtmclay

rtmclay Jul 21, 2024

Member

I have fixed this for me. Please try Lmod 8.7.46 to see if it works for you.

This comment has been minimized.

Copy link
@shiltian

shiltian Jul 22, 2024

Thanks! I'll give it a shot once the new version is on HomeBrew.

This comment has been minimized.

Copy link
@shiltian

shiltian Jul 22, 2024

Unfortunately it is not the case for me. The two variables are still not set, and the export FPATH still runs.

if [ -n "${ZSH_VERSION+x}" -a -z "${__LMOD_SET_ZSH_FPATH+x}" ]; then
  export __LMOD_SET_ZSH_FPATH=1
  zv=${ZSH_VERSION}
  orig_zsh_version=
  zsh_fpath=
  if [ -n "${orig_zsh_version+x}" -a -n "${zsh_fpath+x}" ]; then
    zsh_fpath=$(echo $zsh_fpath | sed -e "s|/$orig_zsh_version/|/$zv/|g" )
    export FPATH=$(/home/linuxbrew/.linuxbrew/Cellar/lmod/8.7.46/libexec/addto --append FPATH $zsh_fpath /home/linuxbrew/.linuxbrew/Cellar/lmod/8.7.46/init/ksh_funcs)
  fi
  unset zv
  unset orig_zsh_version
  unset zsh_fpath
fi

if [ -n "${orig_zsh_version}" -a -n "${zsh_fpath}" ]; then works for me. My bash version is 5.1.16(1)-release and zsh version is 5.8.1.

This comment has been minimized.

Copy link
@rtmclay

rtmclay Jul 22, 2024

Member

Yes, I used the wrong shell foo. The correct version is "${orig_zsh_version:-}". Try Lmod 8.7.47 to see if it works for you. This issue is #716.

export __LMOD_SET_ZSH_FPATH=1
zv=${ZSH_VERSION}
orig_zsh_version=@orig_zsh_version@
zsh_fpath=@zsh_fpath@
zsh_fpath=$(echo $zsh_fpath | sed -e "s|/$orig_zsh_version/|/$zv/|g" )
export FPATH=$(@PKGV@/libexec/addto --append FPATH $zsh_fpath @PKGV@/init/ksh_funcs)
unset zv
unset orig_zsh_version
unset zsh_fpath
fi

SUPPORT_KSH="@support_ksh@"
if [ $SUPPORT_KSH = yes -o -n "${KSH_VERSION+x}" -o -n "${BASH_VERSION+x}" ]; then
if [ -z "${__LMOD_SET_KSH_FPATH:-}" ]; then
export __LMOD_SET_KSH_FPATH=1
export FPATH=$(@PKGV@/libexec/addto --append FPATH $FPATH @PKGV@/init/ksh_funcs)
fi
fi
unset SUPPORT_KSH

export LMOD_ROOT=@lmod_root@
Expand Down

0 comments on commit 1e8cfd4

Please sign in to comment.