Ruby Environment Variables

I had a strange problem with Ruby and Environment variables.

I am currently on an x64 machine running Windows Server 2008 R2

If I do the following in ruby: puts ENV['PROCESSOR_ARCHITECTURE']

I expect to see AMD64, however Ruby shows x86

If I do this: echo %PROCESSOR_ARCHITECTURE% , AMD64 welcomes me on the command line

My Ruby version: ruby ​​1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]

As far as I know, ENV['PROCESSOR_ARCHITECTURE'] should just read my environment variable ...

Any ideas?

Cheers, gareth

+7
ruby
source share
1 answer

It reads your environment variable, but since your ruby ​​executable is compiled for the 32-bit version, it runs in a 32-bit environment where the PROCESSOR_ARCHITECTURE value PROCESSOR_ARCHITECTURE really "x86".

If you put system "echo %PROCESSOR_ARCHITECTURE%" in your ruby ​​script, you will see that it will also output "x86".

+11
source share

All Articles