Cucumber ENV setting in env.rb

I develop in a heterogeneous environment. When I am working with Ruby
on Rails on my laptop then I am inside the bash shell of cygwin running
under MS-WinXPpro.

I also happen to favour a light green on dark green default terminal
display. This renders portions of cucumber’s output, under its default
colour scheme, invisible on both Linux and cygwin. So, I have set up a
custom ENV setting in support/env.rb. Thus:

ENV[“CUCUMBER_COLORS”] =
‘passed=white,bold:passed_param=white,bold,underscore’

When I run rake features this works exactly as I intended under Linux,
but seems to have no effect whatsoever under cygwin. I am working
around this by manually setting the session environment variable and I
could make this solution permanent by altering my .bashrc script. I
nonetheless would like to know why this Ruby setting does not seem to
work in all cases. Is there a special syntax for cygwin/windows? Have
I missed a step and the fact that Linux turns out as expected simply a
coincidence?

James B. wrote:

When I run rake features this works exactly as I intended under Linux,

Evidently not. Setting the ENV inside env.rb does not influence the
rake task display at all. It seems that I must set it externally to
cucumber to have effect.

On Thu, Jan 22, 2009 at 1:38 PM, James B. [email protected]
wrote:

‘passed=white,bold:passed_param=white,bold,underscore’

When I run rake features this works exactly as I intended under Linux,
but seems to have no effect whatsoever under cygwin. I am working
around this by manually setting the session environment variable and I
could make this solution permanent by altering my .bashrc script. I
nonetheless would like to know why this Ruby setting does not seem to
work in all cases. Is there a special syntax for cygwin/windows? Have
I missed a step and the fact that Linux turns out as expected simply a
coincidence?

Cucumber is already initialized when support/env.rb is loaded.

On Windows, cucumber uses win32console to output colors. I cannot
comment on cygwin since I’m not a user of the environment.

You’re mixing cygwin ruby or is native ruby?

Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

On Thu, Jan 22, 2009 at 6:09 PM, Andrew P. [email protected]
wrote:

I never could get Cygwin to display terminal colors in a consistent way.
You’d probably find it easier to install OSX on your laptop!

One thing you could do is try and run an XTerm in cygwin perhaps using a
minimal window manager like ratpoison. This was the best I was able to
manage in getting a decent terminal on windows (Cygwin Ratpoison and
Screen), but in the end I gave up it was just to hard :slight_smile: and inconsistent.

That needs to run a x server to be able to use Xterm… that is way
more complicated…

James: can you tell us if you’re using cygwin ruby or native one?


Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

I never could get Cygwin to display terminal colors in a consistent way.
You’d probably find it easier to install OSX on your laptop!

One thing you could do is try and run an XTerm in cygwin perhaps using a
minimal window manager like ratpoison. This was the best I was able to
manage in getting a decent terminal on windows (Cygwin Ratpoison and
Screen), but in the end I gave up it was just to hard :slight_smile: and
inconsistent.

2009/1/22 James B. [email protected]

On Thu, Jan 22, 2009 at 10:15 PM, James B. [email protected]
wrote:

Luis L. wrote:

James: can you tell us if you’re using cygwin ruby or native one?

I am not sure. I installed cygwin after I had Ruby on that box.

Than you have a native one. Run ruby --version to be sure. What does it
say?

Luis L. wrote:

James: can you tell us if you’re using cygwin ruby or native one?

I am not sure. I installed cygwin after I had Ruby on that box.

Luis

Not quite sure that your criticism is of my post is justified. At no
point
did I say that James should give up on Windows nor give up on Cygwin,
only
that it is very difficult to get the terminal colors to work exactly how
you
want in that environment. This is based on considerable experience
trying to
do precisely this. Nor am I saying that people should not use Windows
for
Rails or that you cannot have an effective Rails setup with Windows.

What I am saying is that having an effective Unix command prompt in
Windows
that you can control with as much precision as in linux or OSX is very
difficult under Windows. If you want to do this (and I really did want
to do
this) then the XTerm approach was more effective at trying to control
terminal colors consistently in comparison to manipulating the standard
cygwin terminal. But whatever you do you will probably have to
compromise
somewhat your terminal experience in comparison to a proper nix.

Andrew

2009/1/22 Luis L. [email protected]

My original observation wrt this problem was inaccurate. The same
behaviour is evidenced in both my Linux and cygwin environments.
Setting the environment variable “CUCUMBER_COLORS” in support/env.rb run
does not alter the behaviour of that run.

As one expects, any environment variable set within a process will not
persist after that process terminates. I lack the experience in either
OS to say whether or not doing so should affect the setting process
itself or only those processes spawned by that parent after the setting
of the variable.

I gathered from the cucumber documentation that the writer expected that
setting the environment in env.rb SHOULD have some effect. However, I
cannot say if that expectation was valid or not.

I am not experiencing any problems with displaying colours or text
enhancements (within the limited ANSI palette) in either environment.

Aslak Hellesøy wrote:

On Thu, Jan 22, 2009 at 10:15 PM,

Luis L. wrote:

James: can you tell us if you’re using cygwin ruby or native one?

I am not sure. I installed cygwin after I had Ruby on that box.

Than you have a native one. Run ruby --version to be sure. What does it
say?

byrnejb@HAL-M13 ~
$ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-cygwin]

Sorry for the delay in my reply.

JBB

We are setting environment variables in our Rakefile. We have various
tasks that set up environment variables, then call the cucumber task.
That’s working for us under windows.

On Fri, Jan 23, 2009 at 8:47 AM, Andrew P. [email protected]
wrote:

Luis

Not quite sure that your criticism is of my post is justified. At no point
did I say that James should give up on Windows nor give up on Cygwin, only
that it is very difficult to get the terminal colors to work exactly how you
want in that environment. This is based on considerable experience trying to
do precisely this. Nor am I saying that people should not use Windows for
Rails or that you cannot have an effective Rails setup with Windows.

You forgot to put a smiley icon along your statement that install OSX
:wink:

What I am saying is that having an effective Unix command prompt in Windows
that you can control with as much precision as in linux or OSX is very
difficult under Windows. If you want to do this (and I really did want to do
this) then the XTerm approach was more effective at trying to control
terminal colors consistently in comparison to manipulating the standard
cygwin terminal. But whatever you do you will probably have to compromise
somewhat your terminal experience in comparison to a proper nix.

I cannot comment too much on cygwin experince, since only used it for
short amount of time and with rxvt. In my experience, I’ve only used
bash directly which provided syntax coloring without issues.

Now, the thing is that I’m talking about MSYS bash, no cygwin, so
dunno how that will work.

XTerm, while it provided a workaround to the problem, and worked as
solution, imposes another requirement for users to use it (you need to
adapt to something different can also not work with other tools).

The nature of console in Windows is far from ideal, but that applies
to native Ruby on Windows

Cygwin Ruby should behave much like *nix, with ansi colors and all that.

As other users commented, setting environment variables is not a
problem on native Windows (I use and abuse of that in a daily basis).

But again, dunno what happens in cygwin island.

I never could get Cygwin to display terminal colors in a consistent way.

Perfection in design is achieved not when there is nothing more to add,
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users


Luis L.
AREA 17

Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

On Fri, Jan 23, 2009 at 3:20 PM, James B. [email protected]
wrote:

My original observation wrt this problem was inaccurate. The same
behaviour is evidenced in both my Linux and cygwin environments.
Setting the environment variable “CUCUMBER_COLORS” in support/env.rb run
does not alter the behaviour of that run.

Updated docs:
http://wiki.github.com/aslakhellesoy/cucumber/console-colours

Josh C. wrote:

We are setting environment variables in our Rakefile. We have various
tasks that set up environment variables, then call the cucumber task.
That’s working for us under windows.

Yes that makes sense. Referring to the Pickaxe book one reads that:

“A Ruby program may write to the ENV object, which on most systems
changes the values of the corresponding environment variables. However,
this change is local to the process that makes it and to any
subsequently spawned child processes. This inheritance of environment
variables is illustrated in the code that follows. A subprocess changes
an environment variable and this change is seen in a process that it
then starts. However, the change is not visible to the original parent.
(This just goes to prove that parents never really know what their
children are doing.)”

This does seem to indicate that the ENV setting made in in env.rb is
visible to the cucumber process. The inference that I draw from this is
that env.rb is processed after the ENV setting for “CUCUMBER_COLORS” has
already been used by cucumber and thus has no further effect on its
behaviour.

On Fri, Jan 23, 2009 at 3:40 PM, James B. [email protected]
wrote:

subsequently spawned child processes. This inheritance of environment
behaviour.
That is correct:

http://github.com/aslakhellesoy/cucumber/blob/cee08ca63fd2d234aacc231d5be342bb6fba06bc/lib/cucumber/formatters/ansicolor.rb

(BTW, this is the ugliest code in Cucumber)

Aslak

Andrew P. wrote:

Have you tried setting the CUCUMBER_COLORS environment variable in your
bash config on cygwin?

James B. wrote:

I am working around this by manually setting the session environment
variable and I could make this solution permanent by altering
my .bashrc script.

Have you tried setting the CUCUMBER_COLORS environment variable in your
bash
config on cygwin?

2009/1/23 James B. [email protected]