Whenever I try to run screen under a Zsh shell that I compiled under my home directory, I get the following error:

> screen
Cannot exec '/my/path/to/zsh/bin/zsh'

The Z shell is perfectly functional, and I have verified that I can run screen if I invoke it using a system shell (e.g. csh). I usually get into zsh with: exec zsh. Here is some additional info about my system:

> echo $SHELL


> which screen

> screen --version
Screen version 4.00.03 (FAU) 23-Oct

My .screenrc just has two lines in it:

escape ^A^A
bind o other

In case it matters: /my/path/to/zsh/ refers figuratively to a path under my home directory.


  1. Output of calling file:

    > file /my/path/to/zsh/bin/zsh
    > /~/sw/zsh/bin/zsh: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for
    > GNU/Linux 2.6.9, dynamically linked (uses shared libs), 
    > for GNU/Linux 2.6.9, stripped
  2. But I can successfully run /my/path/to/zsh/bin/zsh and enter zsh from my csh shell. I usually switch to zsh with exec /my/path/to/zsh/bin/zsh

  3. Below are the ls details on /my/path/to/zsh/bin/zsh

    -rwxr-xr-x 2 YYYY ZZZZ 651K Jan 3 11:58 zsh*
  4. Mi .login is empty (it only has comments on it)

  5. I don't have a .profile file
  6. cat/etc/*-release:

    Scientific Linux SL release 5.1 (Boron)

Any thoughts on what may be causing this and how to get screen to work with my local installation of zsh?

  • Can you execute /my/path/to/zsh/bin/zsh otherwise (with full path)? Is /my/path/to/zsh/bin/zsh by any chance a wrapper script with no she-bang line or an invalid she-bang line? – Stéphane Chazelas Feb 20 '13 at 23:27
  • You should start screen through strace to understand what's going on: `strace -f -o screen.strace screen – Hauke Laging Feb 21 '13 at 1:31
  • Please post the output of file /my/path/to/zsh/bin/zsh and ls -l /my/path/to/zsh/bin/zsh /usr/bin/screen. Are you setting LD_LIBRARY_PATH anywhere? Is this a 32-bit or 64-bit installation, or mixed? – Gilles 'SO- stop being evil' Feb 21 '13 at 1:41
  • If the path is my/path/to/zsh/bin/zsh in your home, it has to be /home/you-the-user/my/path/to/zsh/bin/zsh. If you give a path to a file starting with / that starts at /, always. If it doesn't start with /, it starts at the current directory (~ expands to the home of the user, so an alternative could be ~/my/path/to/zsh/bin/zsh. – vonbrand Feb 21 '13 at 3:09
  • What you report for file /my/path/to/zsh/bin/zsh and ls -l /my/path/to/zsh/bin/zsh are inconsistent. Please copy-paste the real session transcripts, and provide more information about your environment: processor type, unix variant, distribution, anything peculiar about your installation; also how you configured and installed zsh, and anything relevant in your .login, .profile, .cshrc, .zshrc (if in doubt, post everything). – Gilles 'SO- stop being evil' Feb 21 '13 at 19:41

One possible reason is that screen is privileged (on some systems, it's setgid utmp, to be able to log terminal ownership to the utmp file), and that this zsh binary needs a library that isn't in the default library path. Calling a setuid or setgid program erases some environment variables, in particular LD_LIBRARY_PATH.

If you can execute /my/path/to/zsh/bin/zsh from outside screen but not from inside, and you're setting LD_LIBRARY_PATH in your .profile, that would explain your symptoms.

  • Thanks Gilles. I have updated my OP with more info. As a matter of fact, I am manually adding some paths to LD_LIBRARY_PATH both in my .zshrc and .cshrc files, and I need them to be there for other reasons, although I typically switch to zsh with exec /my/path/to/zsh/bin/zsh, so I am not sure if my definitions in .cshrc carry over to zsh. Is there anything I can do knowing this? – Amelio Vazquez-Reina Feb 21 '13 at 16:45

This is embarrassing: the value of of my $SHELL variable was not correct (it had a typo). I apologize - I will make sure I triple check these things before posting a question like this and wasting everyone's time. Thanks so much to all for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.