job.answiz.com
  • 1
Votes
name
name Punditsdkoslkdosdkoskdo

Mac OS X no environment variables when using sudo

I am trying to setup a development environment for nativescript on mac os high sierra.

I installed all the require tools (which contains android sdk, jdk). And added a path (ANDROID_HOME, JAVA_HOME) for both of them using .bash_profile, .bash_rc.

If tns doctor which checks if the environment variables are set - It's all good.

But when I run sudo tns doctor, it says ANDROID_HOME and JAVA_HOME and no configured. I thought this may be more of a mac problem than a nativescript problem.

Any ideas?

From man sudo:

-E
The -E (preserve environment) option indicates to the security policy that the user wishes to preserve their existing environment variables. The security policy may return an error if the -E option is specified and the user does not have permission to preserve the environment.

If you want variables to preserve it's values, call sudo -E tns doctor. You can also call sudo "ANDROID_HOME=$ANDROID_HOME" "JAVA_HOME=$JAVA_HOME" tns doctorto export only these two variables.

  • 0
Reply Report