Ruby cannot see the NLS_LANG environment variable

I run ruby ​​script on CentOS and installed ruby ​​via rvm (1.9.3).

I set the NLS_LANG variable to .bash_profile.

[app@box stasis]$ echo $NLS_LANG
en_US.UTF-8
[app@box stasis]$ which ruby
~/.rvm/rubies/ruby-1.9.3-p194/bin/ruby

However, trying to access it through ruby ​​(which the oci8 driver does), it cannot find it:

 1.9.3-p194 :001 > ENV['NLS_LANG']
 => nil 

Access to other vars seems to work:

 1.9.3-p194 :004 > ENV['USER']
 => "app"

My script shows the following: Warning: NLS_LANG is not set. fallback to US7ASCII.

Thing: I run sqlplus from a ruby ​​script (to execute some .sql files), and special characters are all messed up.

How can I get a ruby ​​to see the value?

+5
source share
1 answer

You need to export the variables so that they are available in any application launches (unless they are functions):

export NLS_LANG

or together with the setting:

export NLS_LANG=en_US.UTF-8

or as in most systems LANGshould be available:

export NLS_LANG=$LANG
+11
source

All Articles