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

JS_RUNTIME_TARGET_BUNDLE not set during heroku ps:exec #18

Closed
ecbrodie opened this issue May 5, 2019 · 9 comments
Closed

JS_RUNTIME_TARGET_BUNDLE not set during heroku ps:exec #18

ecbrodie opened this issue May 5, 2019 · 9 comments

Comments

@ecbrodie
Copy link

ecbrodie commented May 5, 2019

I am trying to deploy a React app not using CRA to Heroku using the create-react-app-buildpack. I am running into a bug that I believe is related to this inner buildpack.

Since I'm not using CRA, I have set a custom path ("dist/") for my bundle.js output. Thus, I am setting a custom path for JS_RUNTIME_TARGET_BUNDLE:

heroku config:set JS_RUNTIME_TARGET_BUNDLE='/app/dist/*.js'

My app has an Nginx 404 page show up on deploy. So, I SSH into the Dyno to check out the issue:

$ heroku ps:exec
Establishing credentials... done
Connecting to web.1 on REDACTED...
ls: cannot access '/app/build/static/js/*.js': No such file or directory
Error injecting runtime env: bundle not found '/app/build/static/js/*.js'. See: https://github.com/mars/create-react-app-buildpack/blob/master/README.md#user-content-custom-bundle-location
$ ...

My natural conclusion is that https://github.com/mars/create-react-app-inner-buildpack/blob/master/.profile.d/inject_react_app_env.sh#L8 is not working properly. I have triple-confirmed that JS_RUNTIME_TARGET_BUNDLE is indeed set on my app and I have forced multiple redeploys. I also have the root set in my static.json file. Not sure what else I can do here to set the custom path to my root.

Thank you for the help.

@mars
Copy link
Owner

mars commented May 5, 2019

JS_RUNTIME_TARGET_BUNDLE definitely works as designed, so something is missing or mistaken in your app's setup.

What does heroku buildpacks return for your app?

What does heroku config return for your app? (Please redact any secrets)

Which git branch are you deploying? And how are you deploying it? (git push or branch auto-deploy)

@ecbrodie
Copy link
Author

ecbrodie commented May 6, 2019

Hey @mars , thanks for the quick reply to my issue, especially on a Sunday!

I will point out that this bug does not appear to be related to deployment. There was an issue with how I was deploying my index.html file to production. I fixed that problem and the app can deploy successfully without unexpected 404 pages.

Rather, I think this bug is solely related to when I SSH into a Dyno via heroku ps:exec. It looks like the JS_RUNTIME_TARGET_BUNDLE variable is not being exported into the shell. Thus, that triggers this error message. Perhaps this is a bug, perhaps it is not a bug (maybe the Heroku platform does not inject configured environment variables when in an SSH session)?

Regardless, thank you for the help.

@mars
Copy link
Owner

mars commented May 6, 2019

The ps:exec shell doesn’t get app config vars, because it’s not the app process. It’s a shell that is running in the container alongside the app process.

@mars mars closed this as completed May 6, 2019
@mars mars changed the title Custom JS_RUNTIME_TARGET_BUNDLE not being respected JS_RUNTIME_TARGET_BUNDLE not set during heroku ps:exec May 6, 2019
@Aakratigoel
Copy link

hey @ecbrodie , I am getting the same error , could you please tell me what did you fix in your index.html file
Thanks

@ecbrodie
Copy link
Author

@Aakratigoel I think it depends where you are getting the error. If it is during ps:exec, then I wouldn't worry. As @mars said, the shell doesn't get config vars injected, so I perceived from this that I should only treat this as an ignorable warning.

If you are getting this error during app deployment, then we got a different problem, which I think should be a new issue.

I can't remember exactly what I did to fix index.html, nor even if it is relevant to this issue anyway. Probably was just a bad path to the Webpack bundle. I encourage you to use Webpack's plugin for dynamically generating index.html files anyway.

@VIPIN-creator
Copy link

VIPIN-creator commented May 23, 2020

@mars @ecbrodie I am also getting same error cannot access '/app/my/custom/path/js/*.js': No such file or directory
I have also tried heroku config:set JS_RUNTIME_TARGET_BUNDLE=/app/my/custom/path/js/*.js. But still getting same error.

on heroku config I am getting JS_RUNTIME_TARGET_BUNDLE: /app/my/custom/path/js/*.js

these are all the errors.

image

@mars
Copy link
Owner

mars commented May 23, 2020

@VIPIN-creator /app/my/custom/path/js/*.js is not a valid path. That’s an example value from the readme. That value should be set to your own custom bundle path.

@VIPIN-creator
Copy link

@mars thank you for the response. But Actually I don't know my custom bundle path.
image

above is the files in my build folder . please help me find out

@mars
Copy link
Owner

mars commented May 24, 2020

@VIPIN-creator your file listing screenshot looks fine to me, using the standard CRA bundle path. I’m not sure what’s wrong for your app. It seems like the files are missing from the Heroku dyno. Did you follow the instructions in the README to set this up? Everything is documented there.

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

No branches or pull requests

4 participants