1

Yes, I have found other questions asking the same:

  1. TERM environment variable not set on mac
  2. TERM environment variable not set
  3. how to remove "TERM environment variable not set"

...


However, my environment variable is set:

$ echo $TERM
xterm-256color

But LLDB does not recognize so:

$ lldb myexecutable
(lldb) target create "myexecutable"
Current executable set to 'myexecutable' (x86_64).
(lldb) platform shell clear
TERM environment variable not set.
error: command returned with status 1

I have my environment variables set up for GUI programs too:

envars.app (applescript application run on logon.)

...
set ENV_TERM to "/bin/launchctl setenv TERM xterm-256color;"
...
do shell script ... & ENV_TERM & ...

or

...
set ENV_TERM to "/bin/launchctl setenv TERM xterm-256color:-dumb;"
...
do shell script ... & ENV_TERM & ...
Community
  • 1
  • 1
Francisco Aguilera
  • 3,099
  • 6
  • 31
  • 57

1 Answers1

2

What you are seeing is the fact that the "platform shell" command doesn't pass lldb's environment to the shell that it spawns. In lldb, the "platform" could be a remote or a local system - depending on what platform you connected to - so using lldb's environment for "platform shell" execution is not always the right thing to do. By default lldb clears out the shell execution environment by default.

But it would be useful to have a flag to "platform shell" that tells it, to use lldb's environment. Feel free to file a bug to this effect with lldb.llvm.org's bugzilla (or wade in and add this yourself if you're feeling bold - it is an open source project...)

Note that when starting a process for debugging under lldb, you do have control over the environment passed. In Command Line lldb, the target.inherit-env setting controls whether the process will inherit lldb's environment, and target.env-vars or the env command can be used to modify the environment. If you are using Xcode, set the environment in the Run Scheme for whatever target you are debugging.

Jim Ingham
  • 25,260
  • 2
  • 55
  • 63