max
August 25, 2017, 5:16am
1
Hi, I’m running build on the stack “Android & Docker, on Ubuntu 16.04 (pre-installed tools)” and I have bash script that starts with #!/usr/bin/env: bash -xe
.
And I’m getting the following error when it is being executed:
/usr/bin/env: ‘bash -xe’: No such file or directory
It is working fine on my local machine
This script is being executed from npm as part of package.json scripts.
Thank you.
daniel
August 25, 2017, 2:59pm
2
Hi @max ,
Can you please add the whole script to check it in context?
1 Like
Did you manage to solve the issue @max ?
max
September 21, 2017, 3:08pm
4
Hello,
Can you please add the whole script to check it in context?
actual script
// hello.sh
#!/usr/bin/env bash -xe
echo "Hello world"
// “scripts” section in package.json
"hello": "./hello.sh"
invokation of the script as part of “Script” step
npm run hello
Did you manage to solve the issue @max ?
I didn’t resolve this issue but I found a workaround of hardcoding path to bash as #!/bin/bash
@max strange… I’d say it’s an npm issue most likely, running the script directly (e.g. as a Script step or from a Script step) works as expected:
+------------------------------------------------------------------------------+
| (0) script@1.1.4 |
+------------------------------------------------------------------------------+
| id: script |
| version: 1.1.4 |
| collection: https://github.com/bitrise-io/bitrise-steplib.git |
| toolkit: bash |
| time: 2017-09-22T12:13:16Z |
+------------------------------------------------------------------------------+
| |
Hello world
| |
+---+---------------------------------------------------------------+----------+
| ✓ | script@1.1.4 | 2.71 sec |
+---+---------------------------------------------------------------+----------+
config:
primary:
steps:
- script@1.1.4:
inputs:
- content: |-
#!/usr/bin/env bash -xe
echo "Hello world"
OK, I think I found the issue.
How the script step runs the given script, and how I tested to run the script: bash /path/to/script
So the script is ran / invoked through bash
directly.
If you simply just chmod +x
the script and try to run you indeed get the error you mentioned:
$ chmod +x test.sh
$ ./test.sh
/usr/bin/env: ‘bash -xe’: No such file or directory
I ran this on a local Ubuntu 17.04
The shebang #!/usr/bin/env bash -xe
works on macOS but not on any Linux I tried.
A bit more debugging: the issue seems to be the -xe
postfix. This works on Linux too:
#!/usr/bin/env bash
set -ex
echo "Hello world"
so #!/usr/bin/env bash
is actually , but on Linux you can’t pass additional params to it, you have to do that in a separate set
command/line.
I hope this helps
1 Like
max
September 22, 2017, 6:25pm
7
Yeah… this approach works, thanks a lot!
1 Like