-
Notifications
You must be signed in to change notification settings - Fork 253
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
#as
and #with
don't work together
#35
Comments
Sounds like, although I'm sure we have tests for how commands are constructed. If it's broken (and I'll take your word for it!) Then I'd really appreciate a PR! |
Fine, I'll get to that soon. |
I wrote a solution to the issue. It's a bit of a hack, but it was the only way I found to adhere to the documentation of how |
I can confirm this issue, it really seems to be broken. Crazy that this has not been revealed earlier :) |
I'm sure we have tests for this, could be that they're broken. I noticed when I ran the suite there were broken tests. Perhaps some could take a look and PR to fix the test suite, maybe that fixes this issue and it's a silly typo or something. |
When I cloned the repository and ran the tests four of them were failing. I tried to fix them, but they had nothing to do with this issue. Therefore, I figured they would be fixed by someone touching other parts of the codebase. This PR leaves those four failing tests untouched. |
Correct, everything is fine - will merge this or give feedback in the next
|
❤️ |
It seems to me that people use I'm afraid of the sshkit codebase running into a corner with all these "quick" patches applied in parallel. But I'd have to blame myself if I don't participate with PRs :) (Just as a side note, my use case is that I would like to source my UPDATE: I very much agree with this issue that switching users should not be done using |
The improved command map is a requirement for Capistrano, and @kirs is a core contributor there, there's been a lot of discussion around this feature.
This is a matter of there being no correct way to do shell escaping if you go ahead and do some escaping yourself, you can pass options to SSHKit also provides
Likewise
I sincerely hope it never comes to that. Relying on system config that's outside of your (direct) control is fragile. |
If someone patches this to work properly (it's clearly a bug) then surely the original problem is solved? You'll still have your dotfile issue, but that's best solved by using the environment mechanisms in SSHKit to code your environment into the script you are running. |
Hi! Thanks for your inspiration. As for this bug, yes, a proper pull request will solve this :) As for my use case, let me try to clarify. Because I don't understand your reasoning (yet) for not relying on "system config that's outside of your (direct) control". Let's say our server has an app and, much like Heroku, the app is configured entirely through environment variables. Also not uncommon, these variables exist in the Now, I don't see a way to use the ssh Are you suggesting that there is a way, in a non-interactive shell, to get all those server environment variables into my session without me having to specify them explicitly on the local machine that executes capistrano? If so, please enlighten me :) PS: Note that there was a update addon on my previous comment. Wouldn't it solve many problems to not rely on sudo in the first place? Just curious. Thank you for your time. You guys are heroes after all :) |
Of course: The Heroku 12FactorApp manifesto is a little extreme, and moreover they're referring to using things like The shell dot files are a file designed to contain helpers for making your interactive shell experience more comfortable. When your application is started by runit, upstart, monit, init.d, god, bluepill and friends, there is no shell, it is not an interactive environment and importantly there are few, or no environment variables (try it by writing a stub init.d file, and having it run Thus the reasoning is clear, if two people have different That's why we script the starting of services, and they always come up in a clean environment, and load their environment, depending on the tooling, from the place that that tool defines that application variables should be stored. |
Comment on #13, this isn't a proposal to "use a different ssh session" (for that use a different |
Hi! Thanks again for your time. I still believe I don't fully understand. Whether my file with the environment variable exports is called In this command example, constructed by sshkit: sudo su my_user -c "/usr/bin/env whoami" ...how would you use sudo su my_user -c "source /file/with/environment/variable/exports; /usr/bin/env whoami" But how would I hook that As for EXPORT, the command is compiled on my local machine, I simply don't have access to the values of the env variables, so I cannot add them one by one from my local machine. In our upstart scripts we define every environment variable explicitly using the env statement. We can do that because, being located on the remote server, we know these variables when we run chef. Even if we would not have direct access to those env variables, we would simply use The
So, I believe we talk about the same thing, but maybe just misunderstand what the other means :) As for #13, thanks, I got it :) |
The point is that you shouldn't start your daemons via SSHkit (or Capistrano, etc). They should be started by something that controls their environment. To cut a long story short; (§10.4.3 The Art of Unix Programming, Raymond, 2003)
So if your app doesn't do the right thing with no env vars, it's incorrect, as far as UNIX conventions go (I heard some guys at Heroku who wrote a manifesto disagree ;-)) if your env vars aren't in the place the system expects them, you are doing something wrong too. It's a matter of taste, I prefer to make sure that my programs don't accidentally misbehave. And in part, you are right, it doesn't matter whether you source I'd consider adding a |
Ok, I feel we are talking about the same thing now :) I'm not starting any deamons and completely agree with that capistrano should not do such weird things. All I need to do is to run a simple I don't see how this cannot be an extremely common capistrano use case :) If not the use case, haha. |
That's why there's What's wrong with |
Thank you for your feedback. I feel less dumb now :) Actually, it is insane to capture() the variables haha. I will opt for monkey patching What is wrong with yaml files is that there is no way to maintain them in your local development environment when you share the repo with developer colleagues (since all those files will be in the .gitignore). Here you really want a no-config application that you can just boot (I don't want all my colleagues and external consultants to ask "why is the app not booting on my computer?" all the time). Note that this does not only apply to database.yml, but to dozens of configuration options, secret keys, URL endpoints, etc. It would be (and indeed it was) painful to maintain yaml files without them being part of the git repository. Even if you could get around that problem by using sane defaults in development, it is painful to maintain the creation of so many yaml files in different places and also write the parsers for them that fetch the options, etc. Well, at least I feel that I'm not the only one thinking about which way would be best to solve this problem :) And yes, I feel that Rails is a good example to hold up the correct way to do things ;) Again, thank you for your inspiration. I am a big fan of the capistrano 3 changes. 👍 |
I'm pretty sure that chef and puppet (or ansible, or salt, or etcd) are all the ways this should be handled correctly, env vars scale to medium sized apps, but not to real hardcore stuff. |
@leehambley above you say
yet I can't seem to find any evidence of this in |
Indeed, apparently we removed it. There used to be an option passable as part of the hash to |
I can confirm that this issue still happens on master and that #144 solves it. Maybe we could accept it, as it less of a hack than my solution, and close this issue. |
@leafac oh, mine's the same amount of hack, don't worry 😄 |
❤️ |
@leafac can you confirm that this solves your issue? What ended up being merged for this was a slightly different approach than when you tested above. |
Yep, all is fine! Thanks, @mtrudel |
The following script triggers the error:
It doesn't print the
FOO
environment variable. This happens because environment variables should be set after calling/usr/bin/env
, not before everything else in the command, as it is.For example, the command generated by the script above is:
$ FOO=bar sudo su root -c "/usr/bin/env env"
It should be:
$ sudo su root -c "/usr/bin/env FOO=bar env"
For this reason, I believe the first example in
README
is broken:Maybe this line in
README
is about this issue:If that is the case, I believe it would be nice to make it clear.
If this is really an issue, please let me know so I can work to fix it.
The text was updated successfully, but these errors were encountered: