Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » Different getenv("PATH") and $PATH on macos M1 (for libclang.dylib)
Re: Different getenv("PATH") and $PATH on macos [message #59494 is a reply to message #59493] Fri, 06 January 2023 06:06 Go to previous messageGo to previous message
Novo is currently offline  Novo
Messages: 1430
Registered: December 2006
Ultimate Contributor
fudadmin wrote on Thu, 05 January 2023 18:05

No. The PATH is set. It is only NOT correctly retrieved with the getenv("PATH") function. Or let'say it is the other PATH set.

But in Terminal one can get the correct one. And I tested it.
And it is also possible to get the correct one with what Oblivion correctly corrected:

Sys("sh -c \'echo $PATH\'");


Do any opendirectoryd API functions/classes exist?
Or anything else what could correctly replace getenv? Or $PATH?
Or any code which is more politically and/or programatically correct than this:
Sys("sh -c \'echo $PATH\'");

?

Yes, it is set. But it is set not by a shell.
According to Set system-wide PATH environment variable for Mac OS GUI apps which is dated 2020 setting PATH via /etc/launchd.conf works.
Comments to "How to set PATH for Finder-launched applications" say that this doesn't work ...
Sys("sh -c \'echo $PATH\'") is a hack. This is not a Macos way. You are not supposed to use shell on Mac. Macos itself doesn't launch shell on login.
This is why I personally wouldn't recommend to use PATH in GUI apps on Mac.
Legally Macos is Unix (and Linux and different flavors of BSD are not), but practically it is something different Smile
I do not know what you need PATH for, but I believe there should be a different way of solving your problem.
Quote:
Do any opendirectoryd API functions/classes exist?
Or anything else what could correctly replace getenv? Or $PATH?
Or any code which is more politically and/or programatically correct than this:

IMHO, if you need shell-related PATH you need to call "sh -c". If you need native Macos PATH you should call regular getenv.
Macos PATH and shell PATH is not the same thing, IMHO. Macos ignores shell.


Regards,
Novo
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Compilation on Linux +GUI,X11
Next Topic: Cannot link with obj generated on custom build step.
Goto Forum:
  


Current Time: Tue Apr 29 22:33:37 CEST 2025

Total time taken to generate the page: 0.01048 seconds