cea-hpc / modules

Environment Modules: provides dynamic modification of a user's environment
http://modules.sourceforge.net/
GNU General Public License v2.0
668 stars 102 forks source link

Execution from a removed working directory #457

Closed zzhang147 closed 2 years ago

zzhang147 commented 2 years ago

Describe the bug

To Reproduce

Steps to reproduce the behavior:

$ module add vscode/1.57.1
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
ERROR: error getting working directory name: no such file or directory
      while executing
  "pwd"
      (procedure "getAbsolutePath" line 9)
      invoked from within
  "getAbsolutePath $modpath"
      (procedure "getModulePathList" line 11)
      invoked from within
  "getModulePathList exiterronundef"
      (procedure "getPathToModule" line 35)
      invoked from within
  "getPathToModule $mod {} $notfounderr"
      (procedure "cmdModuleLoad" line 24)
      invoked from within
  "cmdModuleLoad load 1 {*}$args"
      (procedure "module" line 123)
      invoked from within
  "{*}$execcmdlist"

Location and content of any modulerc or modulefile involved:

$ cat path/to/modulepath/module/version
$ cat path/to/modulepath/module/.modulerc
$ cat path/to/modulepath/.modulerc
...

Expected behavior

Error and debugging information

$ module --debug <command1> <arguments>
$ module --debug <command2> <arguments>
...

Modules version and configuration

$ module 1.57.1
$ module config --dump-state
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Modules Release 5.0.1 (2021-10-16)

- Config. name ---------.- Value (set by if default overridden) ---------------
advanced_version_spec     1
auto_handling             0
avail_indepth             1
avail_output              modulepath:alias:dirwsym:sym:tag:key
avail_terse_output        modulepath:alias:dirwsym:sym:tag
collection_pin_version    0
collection_target         <undef>
color                     auto
colors                    hi=1:db=2:tr=2:se=2:er=91:wa=93:me=95:in=94:mp=1;94:di=94:al=96:va=93:sy=95:de=4:cm=92:aL=100:L=90;47:H=2:F=41:nF=43:S=46:sS=44
contact                   pdl.afs.app.build.lux@mailman.lmera.ericsson.se
csh_limit                 4000
editor                    vi
extended_default          1
extra_siteconfig          <undef>
home                      /app/vbuild/tools/modulestcl/5.0.1
icase                     search
ignored_dirs              CVS RCS SCCS .svn .git .SYNC .sos
implicit_default          1
implicit_requirement      0
list_output               header:idx:variant:sym:tag:key
list_terse_output         header
locked_configs            
mcookie_version_check     1
ml                        1
nearly_forbidden_days     14
pager                     
quarantine_support        0
rcfile                    <undef>
run_quarantine            <undef>
search_match              starts_with
set_shell_startup         0
shells_with_ksh_fpath     
silent_shell_debug        0
siteconfig                /app/vbuild/tools/modulestcl/5.0.1/etc/siteconfig.tcl
tag_abbrev                auto-loaded=aL:loaded=L:hidden=H:hidden-loaded=H:forbidden=F:nearly-forbidden=nF:sticky=S:super-sticky=sS
tag_color_name            
tcl_ext_lib               /app/vbuild/tools/modulestcl/5.0.1/lib/libtclenvmodules.so
term_background           dark
term_width                0
unload_match_order        returnlast
variant_shortcut          
verbosity                 concise
wa_277                    0

- State name -----------.- Value ----------------------------------------------
always_read_full_file     1
autoinit                  0
clock_seconds             1652942817
cmdline                   /app/vbuild/tools/modulestcl/5.0.1/libexec/modulecmd.tcl bash config --dump-state
commandname               config
domainname                sero.gic.ericsson.se
error_count               0
extra_siteconfig_loaded   0
false_rendered            0
force                     0
hiding_threshold          0
inhibit_errreport         0
inhibit_interp            0
init_error_report         1
is_stderr_tty             1
is_win                    0
kernelversion             #1 SMP Fri Sep 24 10:17:16 UTC 2021
lm_info_cached            0
machine                   x86_64
modulefile                {}
nodename                  seroiuts00954.sero.gic.ericsson.se
os                        Linux
osversion                 3.10.0-1160.45.1.el7.x86_64
paginate                  0
path_separator            :
report_format             regular
reportfd                  stderr
return_false              0
shell                     bash
shelltype                 sh
siteconfig_loaded         1
sub1_separator            &
sub2_separator            |
subcmd                    config
subcmd_args               --dump-state
tcl_ext_lib_loaded        0
tcl_version               8.6.4
term_columns              238
try_modulefile            0
usergroups                eusers rnd npeeradiosw npeeradioswtpc
username                  ehhzeza

- Env. variable --------.- Value ----------------------------------------------
LOADEDMODULES             isit_modules
MODULEPATH                /app/modules/0/modulefiles:/env/sero/modules:/home/ehhzeza/.afs/0/imodules:/env/common/modules
_LMFILES_                 /home/ehhzeza/.afs/0/imodules/isit_modules

Additional context

xdelaruelle commented 2 years ago

@zzhang147 More information is expected to understand what the issue is. Especially, could you provide the output of the following command:

$ module config -DD --dump-state

And also the content of all the RC files that will be mentioned by this debug report.

zzhang147 commented 2 years ago

after a few minutes this issue not seen again.

xdelaruelle commented 2 years ago

After some searches, I have found that this error is obtained when the current working directory where the module command is executed is removed:


$ mkdir test
$ cd test
$ rmdir ../test
$ module
ERROR: error getting working directory name: no such file or directory
      while executing
  "pwd"
      (procedure "getAbsolutePath" line 9)
      invoked from within
  "getAbsolutePath $fpath"
      (procedure "cmdModuleSource" line 3)
      invoked from within
  "cmdModuleSource load $rc"
      (procedure "runModulerc" line 23)
      invoked from within
  "runModulerc"
      (procedure "module" line 110)
      invoked from within
  "{*}$execcmdlist"
  Please report this issue at https://github.com/cea-hpc/modules/issues
xdelaruelle commented 2 years ago

I am updating code to make it clear this situation is not a modulecmd.tcl issue.