Forum: RSpec Cucumber ENV setting in env.rb

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-22 16:38
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?
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-22 20:21
James Byrne 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.
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2009-01-22 20:33
(Received via mailing list)
On Thu, Jan 22, 2009 at 1:38 PM, James Byrne <lists@ruby-forum.com>
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 Lavena
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
85d99e7678d8720f6e00ab0f60fe6ea9?d=identicon&s=25 Andrew Premdas (Guest)
on 2009-01-22 21:31
(Received via mailing list)
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 :) and
inconsistent.



2009/1/22 James Byrne <lists@ruby-forum.com>
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2009-01-22 21:47
(Received via mailing list)
On Thu, Jan 22, 2009 at 6:09 PM, Andrew Premdas <apremdas@gmail.com>
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!
>

http://rubyonwindows.blogspot.com/2009/01/amen-brother.html

> 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 :) 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 Lavena
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
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-22 22:15
Luis Lavena 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.
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-01-22 23:36
(Received via mailing list)
On Thu, Jan 22, 2009 at 10:15 PM, James Byrne <lists@ruby-forum.com>
wrote:

> Luis Lavena 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?
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-23 04:26
Aslak Hellesøy wrote:
> On Thu, Jan 22, 2009 at 10:15 PM,
>
>> Luis Lavena 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
85d99e7678d8720f6e00ab0f60fe6ea9?d=identicon&s=25 Andrew Premdas (Guest)
on 2009-01-23 11:55
(Received via mailing list)
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 Lavena <luislavena@gmail.com>
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-23 15:20
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.
71093e95d940db3009c9aae19969442a?d=identicon&s=25 Josh Chisholm (Guest)
on 2009-01-23 15:20
(Received via mailing list)
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.
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2009-01-23 15:27
(Received via mailing list)
On Fri, Jan 23, 2009 at 8:47 AM, Andrew Premdas <apremdas@gmail.com>
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
;-)

> 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,
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>



--
Luis Lavena
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
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-23 15:40
Josh Chisholm 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.
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-01-23 15:46
(Received via mailing list)
On Fri, Jan 23, 2009 at 3:20 PM, James Byrne <lists@ruby-forum.com>
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/cons...
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-01-23 16:57
(Received via mailing list)
On Fri, Jan 23, 2009 at 3:40 PM, James Byrne <lists@ruby-forum.com>
wrote:

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

http://github.com/aslakhellesoy/cucumber/blob/cee0...

(BTW, this is the ugliest code in Cucumber)

Aslak
85d99e7678d8720f6e00ab0f60fe6ea9?d=identicon&s=25 Andrew Premdas (Guest)
on 2009-01-23 19:31
(Received via mailing list)
Have you tried setting the CUCUMBER_COLORS environment variable in your
bash
config on cygwin?


2009/1/23 James Byrne <lists@ruby-forum.com>
171ea139761951336b844e708d1547ab?d=identicon&s=25 James Byrne (byrnejb)
on 2009-01-23 21:07
Andrew Premdas wrote:
> Have you tried setting the CUCUMBER_COLORS environment variable in your
> bash config on cygwin?

James Byrne 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.
This topic is locked and can not be replied to.