Chris reports:
(05:09:16 PM) Chris Reece: Well, I got an amusing "evergreen-boilerplate-generator: command not found" error
And belatedly tells me the rather important detail that it's Windows. I can reproduce it, every time, as you'd expect:
bash: c:\Program Files\software.jessies.org\evergreen\Resources\evergreen\bin\evergreen-boilerplate-generator: command not found
Ah, be fair. If I'd been reporting it, I'd have given you the full spec.
What I actually said was:
Chris Reece says: I'm not bothered enough taht I'm willing to join the
Googlegroup.
;)
Now, if I can repeat the "correct indentation" problem I had under
SPARC/Solaris 10 with Python source, *that* I'll report. And I've amended my
Googlegroup membership. But, as you suggested via IM, it doesn't seem to be a
general problem; I can't repeat it at work.
On Windows.
bash-3.2$ which python
/usr/bin/python
bash-3.2$ python -V
Python 2.5.1
bash-3.2$ which ruby
/usr/bin/ruby
bash-3.2$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-cygwin]
bash-3.2$ which evergreen-boilerplate-generator
/cygdrive/c/Program
Files/software.jessies.org/evergreen/Resources/evergreen/bin/evergreen-boilerplate-generator
The code in NewFileAction.java for choosing the boilerplate generator is not working as intended. evergreen-boilerplate-generator will always be on the path, thanks to subvertPath in invoke-java.rb. (Although that subvertPath code isn't very old, it does look older than this code, so I don't think the problems I'm writing up here are even partly a regression introduced by invoke-java.rb changes.) It's lucky that evergreen-boilerplate-generator is always on the path, or the toString call would die with a null pointer exception. Because this is never null, the "return" is dead code. I'm not sure what the intention was behind that conditional and indeed behind having the property at all.
Perhaps Elliott intention would be best fulfilled by moving evergreen-boilerplate-generator to lib/scripts/, which isn't on the path (so we'd use the new getScriptFilename to run it), explicitly if there's no evergreen-boilerplate-generator on the path (and no property, if we still want the property). One possible intention for the property is to give the user a way of disabling the default boilerplate. In that case, perhaps we should be testing the property for equality to "". A more obvious way of achieving the same end would be to have an evergreen-boilerplate-generator higher up the path that outputs nothing.
The most expedient way for me to fix both the bugs described above and the one below would be to always use the string "evergreen-boilerplate-generator" and to swap the two lines in invoke-java.rb that add components to the path. That would have the effect of moving the default evergreen-boilerplate-generator to the end of the path, allowing the user can override it once again.
I imagine that Elliott's response so far would include the suggestion that we should ditch subvertPath entirely. Although it's inadequately commented, one purpose that's currently serving is to facilitate finding the appropriate architecture's support binaries (but not shared libraries). That's currently being used for setsid and perhaps for some of the native Mac tools. We want to use our setsid on Windows even in the unlikely event that the user has installed Cygwin's util-linux package. We could solve that another way. One way would be to rename our program (again). I don't know why I hadn't learned the lesson that, if doesn't walk like a duck, then it shouldn't be called "duck". Anyway, my point here was really that we could avoid putting the application's "bin" directory, which actually contains scripts rather than binaries, on the PATH while still putting our support binaries, which are in architecture-specific directories, on the PATH.
If we want to move evergreen-boilerplate-generator to lib/scripts/, then I'll have to fix Chris's bug by translating a Unix style command line which contains Windows filenames (with their backslashes, drive letters and spaces - and we will have a space in the path to evergreen-boilerplate-generator) into something Cygwin bash will accept. That's probably impossible to get right in the general case. :(
Another option would be to change the signature of ProcessUtilities.makeShellCommandArray so that, instead of being passed a command line, it would be passed an array of arguments. That sounds like a deal of work but perhaps not too much and it would give us a place to do quoting right. The dubious quoting in eg CheckForLintAction.java hasn't bitten us, except perhaps on Windows. The callers that pass in Windows paths would have to wrap those strings with calls to something like FileUtilities.performCygwinRewrites (exactly like that function except performing the reverse translation). This feels like the high-quality solution to me, but it is a deal of work and it would inevitably suffer from incompleteness, when people forget to call the Cygwin-specific wrapper with their script paths.
private void fillWithInitialContents(File file) {
// FIXME: we could use FileType.guessFileTypeByFilename to allow the user to specify scripts that override a single type. YAGNI.
String defaultBoilerplateGenerator = FileUtilities.findOnPath("evergreen-boilerplate-generator").toString();
String boilerplateGenerator = Parameters.getParameter("boilerplateGenerator", defaultBoilerplateGenerator);
if (boilerplateGenerator == null) {
return;
}
(Perhaps filling in the missing information is worth the risk of forking the thread when we were making good progress on the other branch.)
Not finding the interpreter and lack of executability were my first two thoughts too but the problem is actually that we're running:
"setsid", "bash", "--login", "-c", "C:\i\don't\remember\the\exact\path\and\reece\chopped\off\the\tail\of\the\email\thread\in\some\doubtless\well-intentioned\but\annoying\reminder\of\the\days\when\we\couldn't\afford\the\bandwidth\for\fulltext-unten\bin\evergreen-boilerplate-generator"
Cygwin bash doesn't like Windows paths, eg:
martind@mdorey ~
$ 'C:\cygwin\bin\ls'
bash: C:\cygwin\bin\ls: command not found
martind@mdorey ~
$ 'C:\cygwin\bin\ls.exe'
bash: C:\cygwin\bin\ls.exe: command not found
martind@mdorey ~
$
-----Original Message-----
From: evergre...@googlegroups.com
[mailto:evergre...@googlegroups.com]
On Behalf Of Chris Reece
Sent: Wednesday, April 01, 2009 18:44
To: evergre...@googlegroups.com
Cc: evergre...@googlegroups.com
Subject: Re: boilerplate generator not found Evergreen problem
(1563/2939/1.6.0_11-b03/Windows 2000 5.0 Cygwin 1.5.25/x86 x1)
I don't know about any of that, but:
> if no-one but me is overriding this at the moment, maybe just get-
> property() and then find-in-script-dir().
Properties resurgent? Sigh. Well, I look forward to the UI.
> i put it here to facilitate it being on the path. for most of our
> backquoted scripts
Is that just of historical interest or is that you saying, as it seems, that you want evergreen-boilerplate-generator left in /usr/bin?
> the only way things get used is by making the right code the simpler,
> prettier choice.
Laudable, I'm sure, but I'm really skeptical as to whether that's possible here. If we switch to a Cygwin execvp, then we go from requiring all of our script names to be translated to needing their arguments translated. That's probably a smaller problem and we don't then have to pass everything via the shell.
We could wrap the existing spawn and do our own hash-bang interpretation. That might get us somewhere, if we never need the shell. On which subject, this seems backwards:
> FileIgnorer is actually the only
> case i can see in Evergreen where we call makeShellCommandArray but
> never need to (because the command contains no user-supplied part)
In the case of, say, PerlDocumentationResearcher, we shouldn't be letting the user's input be interpreted as shell metacharacters. The user-specified part should be a single argument. CheckForLintAction would be safer if it didn't use the shell. The predefined checkers could easily be specified as String[] or we could split at space. We could assume the same for user checkers. If that inconvenienced anyone, then they could use an intermediary script. One of ManPageResearcher's two calls invites research into Little Bobby Tables' cousin Semicolon Remove Home Directory, something that we then have to go out of way to prevent:
// We don't just test for the "man:" prefix because we're going to send the rest directly to a shell, so we don't want any nasty surprises.
Pipelines would be a pain but we never seem to want anything more complicated than one pipe.
This is simple and not too ugly:
command += " \"" + FileUtilities.parseUserFriendlyName(filename) + "\"";
But also wrong. Still, it's interesting that we're wrapping our script argument. If it's buggered without wrapping on all platforms, then maybe it's not so unworkable, to have the wrapper do something Cygwin-specific, after all.
>
> (2) a "shell window" tool that starts Terminator in
> $EDIT_CURRENT_DIRECTORY (how is that not there by default? )
Is it not? I've got one, did I add mine indepedently?
-ed
one of the mistakes we've made with properties in the past was that we
only had one properties file, and we used it to hard-code defaults _and_
for user configuration. we've moved away from that, but we never removed
or disabled the old files. so someone who's been using Evergreen since
before it was called Evergreen is likely to have all kinds of random
cruft.
for some time now, we've not been writing an "edit.properties" file at
all. so new users won't even have a file, let alone anything in it. if i
could actually rely on people to notice and/or mention it, an easy way to
find out what people are using would be to switch to looking for
"evergreen.properties" instead!
>
> On Sat, April 4, 2009 12:30, Ed Porter wrote:
>> On 4 Apr 2009, at 21:14, Martin Dorey wrote:
>>> (2) a "shell window" tool that starts Terminator in
>>> $EDIT_CURRENT_DIRECTORY (how is that not there by default? )
>>
>> Is it not? I've got one, did I add mine indepedently?
>
> one of the mistakes we've made with properties in the past was that we
> only had one properties file, and we used it to hard-code defaults
> _and_
> for user configuration.
That'll be where mine came from then.
When I updated Evergreen for the first time in ages the other day, I
was surprised to find my 'rebuild everything' command which has been
attached to ctrl-shift-b for longer than I can remember didn't work;
it had been hijacked by a command which failed in my environment
('make test').
User-defined keyboard actions should take precedence over hard-coded
defaults.
-ed
yes, or there should at least be a warning. there's a to-do, but external
tools see such light use (probably because there's neither UI nor
documentation, and you have to restart Evergreen for changes to take
effect) that it's never been a priority.
> don't we just want to switch to new String[] { boilerplateGenerator,
> file.toString() }
You had what I understood to be a hypothetical counter-example yesterday, where the property was specifying a bash command line rather than the name of a script. That apparently didn't work anyway for some quoting reason. Can I assume that we ain't gonna need that? The user can always have an intermediary script to run the command line for them. If so, then I think we can solve the Cygwin boilerplate issue without the disruption of a new process builder, though I do like your suggested syntax and it's not without other motivation, agreed upon below.
Perhaps I should move the finding of the interpreter to ProcessUtilities next and before touching NewFileAction, so that NewFileAction doesn't require an explicit "ruby" and hence the same FIXME/caveat as I just added to GoToTagAction.