Skip to main content
Tweeted twitter.com/StackUnix/status/692675505502437376
added information posted as comments
Source Link
Gilles 'SO- stop being evil'
  • 865.2k
  • 205
  • 1.8k
  • 2.3k

Why is the portable shebang#!/usr/bin/env bash not working on my system?

I ran into some issues when running some installation scripts where they complained of bad interpreter.

So I made a trivial example but I can't figure out what the problem is, see below.

#!/usr/bin/env bash
echo "hello"

Executing the script above results in the following error

[root@ech-10-24-130-154 dc-user]# ./junk.sh
bash: ./junk.sh: /usr/bin/env: bad interpreter: No such file or directory

The /usr/bin/env file exists, see below:

[root@ech-10-24-130-154 dc-user]# ls -l /usr/bin/env
lrwxrwxrwx 1 root root 13 Jan 27 04:14 /usr/bin/env -> ../../bin/env
[root@ech-10-24-130-154 dc-user]# ls -l /bin/env
-rwxr-xr-x 1 root root 23832 Jul 16  2014 /bin/env
[root@ech-10-24-130-154 dc-user]#

If I alter the script to use the regular shebang #!/bin/bash it works no problem. #!/bin/env bash works as well.

What is missing from the environment to allow the portable shebang to work?

ls -lL /usr/bin/env returns ls: cannot access /usr/bin/env: No such file or directory so I guess I need to alter the symbolic link? Can I point it to /bin/env?

env --version is 8.4 and the OS is Red Hat Enterprise Linux Server release 6.6.

Why is the portable shebang not working on my system?

I ran into some issues when running some installation scripts where they complained of bad interpreter.

So I made a trivial example but I can't figure out what the problem is, see below.

#!/usr/bin/env bash
echo "hello"

Executing the script above results in the following error

[root@ech-10-24-130-154 dc-user]# ./junk.sh
bash: ./junk.sh: /usr/bin/env: bad interpreter: No such file or directory

The /usr/bin/env file exists, see below:

[root@ech-10-24-130-154 dc-user]# ls -l /usr/bin/env
lrwxrwxrwx 1 root root 13 Jan 27 04:14 /usr/bin/env -> ../../bin/env
[root@ech-10-24-130-154 dc-user]# ls -l /bin/env
-rwxr-xr-x 1 root root 23832 Jul 16  2014 /bin/env
[root@ech-10-24-130-154 dc-user]#

If I alter the script to use the regular shebang #!/bin/bash it works no problem.

What is missing from the environment to allow the portable shebang to work?

Why is #!/usr/bin/env bash not working on my system?

I ran into some issues when running some installation scripts where they complained of bad interpreter.

So I made a trivial example but I can't figure out what the problem is, see below.

#!/usr/bin/env bash
echo "hello"

Executing the script above results in the following error

[root@ech-10-24-130-154 dc-user]# ./junk.sh
bash: ./junk.sh: /usr/bin/env: bad interpreter: No such file or directory

The /usr/bin/env file exists, see below:

[root@ech-10-24-130-154 dc-user]# ls -l /usr/bin/env
lrwxrwxrwx 1 root root 13 Jan 27 04:14 /usr/bin/env -> ../../bin/env
[root@ech-10-24-130-154 dc-user]# ls -l /bin/env
-rwxr-xr-x 1 root root 23832 Jul 16  2014 /bin/env
[root@ech-10-24-130-154 dc-user]#

If I alter the script to use the regular shebang #!/bin/bash it works no problem. #!/bin/env bash works as well.

What is missing from the environment to allow the portable shebang to work?

ls -lL /usr/bin/env returns ls: cannot access /usr/bin/env: No such file or directory so I guess I need to alter the symbolic link? Can I point it to /bin/env?

env --version is 8.4 and the OS is Red Hat Enterprise Linux Server release 6.6.

Source Link
conorgriffin
  • 1.6k
  • 6
  • 17
  • 23

Why is the portable shebang not working on my system?

I ran into some issues when running some installation scripts where they complained of bad interpreter.

So I made a trivial example but I can't figure out what the problem is, see below.

#!/usr/bin/env bash
echo "hello"

Executing the script above results in the following error

[root@ech-10-24-130-154 dc-user]# ./junk.sh
bash: ./junk.sh: /usr/bin/env: bad interpreter: No such file or directory

The /usr/bin/env file exists, see below:

[root@ech-10-24-130-154 dc-user]# ls -l /usr/bin/env
lrwxrwxrwx 1 root root 13 Jan 27 04:14 /usr/bin/env -> ../../bin/env
[root@ech-10-24-130-154 dc-user]# ls -l /bin/env
-rwxr-xr-x 1 root root 23832 Jul 16  2014 /bin/env
[root@ech-10-24-130-154 dc-user]#

If I alter the script to use the regular shebang #!/bin/bash it works no problem.

What is missing from the environment to allow the portable shebang to work?