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

Heroku failing to find settings.json on launch #31

Open
trustieee opened this issue Jun 23, 2015 · 10 comments
Open

Heroku failing to find settings.json on launch #31

trustieee opened this issue Jun 23, 2015 · 10 comments

Comments

@trustieee
Copy link

I've posted about this on stack overflow.

I've ensured config:set is METEOR_SETTINGS="$(cat settings.json)" and Heroku fails to find it at runtime.

Not sure if it's buildpack related, but basically Heroku is not finding my settings.json while following the steps laid out in the readme here.

@wfleming
Copy link
Collaborator

What is the value of METEOR_SETTINGS if you run heroku config?

It sounds like something about your shell configuration may mean the $() method of putting the output of the cat command into the heroku config:set command isn't working. The idea of that command from the README is that the value of the METEOR_SETTINGS env var on Heroku should end up being the text content of your settings.json file, not the literal string "$(cat settings.json)".

@trustieee
Copy link
Author

Value of METEOR_SETTINGS is:

METEOR_SETTINGS: 'cat settings.json'

If that's not the recommended approach, what is a way to ensure that my app on Heroku grabs the contents of settings.json when ran? As right now the error Heroku spits out is:

Error: METEOR_SETTINGS are not valid JSON: 'cat settings.json'

@wfleming
Copy link
Collaborator

As far as I know, you can't set it up to pickup settings.json at run time, because the app running on your dyno has been compiled into a plain Node app. Current best practice I've seen suggested on other hosts (specifically modulus.io) is the same as in this buildpack's README: put the contents of the settings.json in an env var.

I would recommend either 1) figuring out why heroku config:add METEOR_SETTINGS="$(cat settings.json)" isn't doing the correct thing or 2) manually copying the contents of your settings.json file into the heroku command to set your environment for now.

Option 2 there is kind of a pain, and more of a temporary bandaid than a real fix.

For actually figuring out why the README command isn't working for you, what shell do you use, and what environment are you working in? When you run heroku config:set METEOR_SETTINGS="$(cat settings.json)" in your shell, what is the output?

@trustieee
Copy link
Author

Running on Windows - but have access to commands like cat/ls/etc...

Setting config vars and restarting XXX... done, v22
METEOR_SETTINGS: $(cat settings.json)

So what really should happen is the output of cat settings.json should be fed into METEOR_SETTINGS at the time of running config:set.

@wfleming
Copy link
Collaborator

Ah, are you using PuTTY, or a different way of getting unix tools on Windows? Are you running these commands in PowerShell, or a bash shell, or something else?

Not knowing the specifics, you could try some variants of the $() command substitution syntax: it may be that your setup isn't running it because it doesn't know that syntax, or maybe because it's quoted. Some different variations that may work (without just copy-pasting file contents by hand):

  • heroku run config:set METEOR_SETTINGS="cat settings.json"
  • heroku run config:set METEOR_SETTINGS=$(cat settings.son)
  • heroku run config:set METEOR_SETTINGS=cat settings.json

@trustieee
Copy link
Author

Getting closer - had to switch to powershell from "cmder". The output of the file is interpreted but the quotes are stripped around the json keys, which looks to be happening due to heroku and not powershell.

{   mode: prod,   public: {     initiativeLimit: 5   } }

This is the output when running:

heroku config:set METEOR_SETTINGS=$(cat settings.json)

However when running: $(cat settings.json) the output is correct and maintains the quotes from the file's json.

Looking further into this (hoping keeping the conversation here will help others on Windows who don't want to manually get the contents of the file, minify it, and set it each time)

@trustieee
Copy link
Author

Even manually running:

heroku config:set METEOR_SETTINGS="{"foo":"bar"}"

... fails, as the quotes inside are stripped out. Need to instead manually escape each quote like this:

heroku config:set METEOR_SETTINGS="{\"foo\":\"bar\"}"

Fun times.

@wfleming
Copy link
Collaborator

Did you try the original form METEOR_SETTINGS="$(cat settings.json)" in powershell? Just curious.

Yeah, sorry it's such a pain: Window's command line stuff is not usually terribly pleasant, and I don't have much experience with it. You could write a ruby script to do the hard stuff for you, of course, which may be a useful thing to do if you expect to change settings often.

@haotangio
Copy link

  • Open git bash CLI of Windows.
  • heroku config:set METEOR_SETTINGS="$(cat settings.json)"
  • Enjoy :)

@egorgrushin
Copy link

@haotangio Very thanks man! Why it works only in git bash CLI?

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