RSpec newbie ran rspec 2.4 on WinXP, got HOME undefined

Hi,

I’m running WinXP-Pro/SP3 & Ruby 1.8.6

I just got the RSpec Book and successfully ran
gem install rspec --version 2.0.0
per the book’s suggestion.

In a Command window, I ran
K:>rspec -v
and got:
K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec-
core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn’t find
HOME environment – expanding `~’ (ArgumentError)

I ran “gem install rspec -v 2.4.0” successfully and got the same
symptom,
except this time the intermediate portions of the error message
referred to
gems/1.8/gems/rspec-core-2.4.0

I checked my environment variables for HOME; it is undefined.

Could it be that RSpec relies on some Ruby 1.9 functionality?

Any advice would be gratefully received.

Richard

On Monday 10 January 2011 22.37:46 RichardOnRails wrote:

Hi,

I’m running WinXP-Pro/SP3 & Ruby 1.8.6

K:/_Utilities/ruby186-26_rc2/ruby/lib/ruby/gems/1.8/gems/rspec-
core-2.4.0/lib/rspec/core/configuration_options.rb:9:couldn’t find
HOME environment – expanding `~’ (ArgumentError)

I checked my environment variables for HOME; it is undefined.

Sounds like rspec is relying on some *NIX stuff here (HOME is usually
pointing
to a users home directory). Google how to set environment variables and
set
HOME to the folder containing your home directory (usually something
like
C:\documents and settings<user>).

Hi Simon,

Sounds like rspec is relying on some *NIX stuff here
Yeah, I recognized that it was looking for a home directory on a *nix
box, but I couldn’t think of a counterpart on Windows, because I’ve
only got a slew of partitions (C:, D:\ …) but no home.

You came up with a good insight. I tried my admin subdir in Documents
and Settings and noted that one of the subdirectories was gem. That
sounded good, but no prize. So I did a search of DandS for rspec.
Found a good subdir with lots of rspec entries.

Set HOME to that via the control panel. Started a new Command Window
so that the new settings would be read in and got.

K:>rspec -v
2.4.0

Mission Accomplished.

Thanks for your keen insights.
Richard

K:>

On Mon, Jan 10, 2011 at 6:37 PM, RichardOnRails
[email protected] wrote:

and got:
I checked my environment variables for HOME; it is undefined.

Could it be that RSpec relies on some Ruby 1.9 functionality?

File.expand_path("~")

That could trigger the issue. expand_path on 1.8.x depends on HOME
been defined. Ruby 1.9 already workaround that properly checking for
HOMEDRIVE+HOMEPATH, USERPROFILE and HOME

You can avoid that setting HOME to HOMEDRIVE+HOMEPATH:

SET HOME=%HOMEDRIVE%%HOMEPATH%

And put that in your user environment variables.

No other workaround for tilde expansion for 1.8.x


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-Exupry