Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibazel run doesn't work, beginning with v2.1.0 #143

Closed
drmercer-lucid opened this issue Mar 30, 2022 · 3 comments · Fixed by #226
Closed

ibazel run doesn't work, beginning with v2.1.0 #143

drmercer-lucid opened this issue Mar 30, 2022 · 3 comments · Fixed by #226

Comments

@drmercer-lucid
Copy link
Contributor

drmercer-lucid commented Mar 30, 2022

Hi team,

We have a Spring server built using bazel, and we use ibazel for local development. ibazel run //atlassian-embed should run the Spring server and automatically restart when any of the source files change. This was working great on rules_spring 2.0.0, but after upgrading to 2.1.0 or higher, ibazel run fails with these errors:

[bazel-bin]/atlassian-embed/atlassian-embed_deploy: 8: Bad substitution
[bazel-bin]/atlassian-embed/atlassian-embed_deploy: 11: source: not found

(Where [bazel-bin] is the full path of the bazel-bin dir.) Looking at the release notes for 2.1.0, I see some changes were made around the run script; I'll look into those and see if I can find a fix, but figured it'd be worth opening this anyway in case anyone else runs into this issue.

@plaird
Copy link
Contributor

plaird commented Mar 30, 2022

As a workaround, it may be helpful to use the custom launcher script option:
https://github.com/salesforce/rules_spring/blob/master/springboot/bazelrun.md#custom-launcher-script

until we resolve this (which appears to be a variant of #110 as you mentioned).

@plaird plaird added the bug label Mar 30, 2022
@drmercer-lucid
Copy link
Contributor Author

drmercer-lucid commented Mar 30, 2022

As a workaround, it may be helpful to use the custom launcher script option:

Unfortunately, this failure seems to happen in the script that launches the (possibly custom) launcher script. This is the source of the script that's failing (the atlassian-embed_deploy script in the error above):

# ***************************************************************
# Outer launcher script for "bazel run"
_bazelrun_script_template = """
#!/bin/bash
set -e
# bring in the resolved variables needed for running the script
# SCRIPT_DIR is the directory in which bazel run executes
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# the env variables file is found in SCRIPT_DIR
source $SCRIPT_DIR/bazelrun_env.sh
# the inner bazelrun script is found in the runfiles subdir
# this is either default_bazelrun_script.sh or a custom one provided by the user
source %bazelrun_script%
"""

I've worked around this by just downgrading to 2.0.0, so this isn't urgent. 🙂 Just something that ideally would be fixed so we can upgrade without losing ibazel. I'll take a stab at debugging it myself with a local clone of rules_spring, if I have time.

@drmercer-lucid
Copy link
Contributor Author

I believe I found the problem. There's a newline before the shebang in the generated wrapper script:

_bazelrun_script_template = """
#!/bin/bash

This change fixes it:

-_bazelrun_script_template = """
-#!/bin/bash
+_bazelrun_script_template = """#!/bin/bash

I'll try to open a PR soon, but won't be upset if someone beats me to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants