1 //! Inspection and manipulation of the process's environment.
3 //! This module contains functions to inspect various aspects such as
4 //! environment variables, process arguments, the current directory, and various
5 //! other important directories.
7 //! There are several functions and structs in this module that have a
8 //! counterpart ending in `os`. Those ending in `os` will return an [`OsString`]
9 //! and those without will return a [`String`].
11 #![stable(feature = "env", since = "1.0.0")]
16 use crate::error::Error;
17 use crate::ffi::{OsStr, OsString};
20 use crate::path::{Path, PathBuf};
22 use crate::sys::os as os_imp;
24 /// Returns the current working directory as a [`PathBuf`].
28 /// Returns an [`Err`] if the current working directory value is invalid.
31 /// * Current directory does not exist.
32 /// * There are insufficient permissions to access the current directory.
39 /// fn main() -> std::io::Result<()> {
40 /// let path = env::current_dir()?;
41 /// println!("The current directory is {}", path.display());
45 #[stable(feature = "env", since = "1.0.0")]
46 pub fn current_dir() -> io::Result<PathBuf> {
50 /// Changes the current working directory to the specified path.
52 /// Returns an [`Err`] if the operation fails.
58 /// use std::path::Path;
60 /// let root = Path::new("/");
61 /// assert!(env::set_current_dir(&root).is_ok());
62 /// println!("Successfully changed working directory to {}!", root.display());
64 #[doc(alias = "chdir")]
65 #[stable(feature = "env", since = "1.0.0")]
66 pub fn set_current_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
67 os_imp::chdir(path.as_ref())
70 /// An iterator over a snapshot of the environment variables of this process.
72 /// This structure is created by [`env::vars()`]. See its documentation for more.
74 /// [`env::vars()`]: vars
75 #[stable(feature = "env", since = "1.0.0")]
80 /// An iterator over a snapshot of the environment variables of this process.
82 /// This structure is created by [`env::vars_os()`]. See its documentation for more.
84 /// [`env::vars_os()`]: vars_os
85 #[stable(feature = "env", since = "1.0.0")]
90 /// Returns an iterator of (variable, value) pairs of strings, for all the
91 /// environment variables of the current process.
93 /// The returned iterator contains a snapshot of the process's environment
94 /// variables at the time of this invocation. Modifications to environment
95 /// variables afterwards will not be reflected in the returned iterator.
99 /// While iterating, the returned iterator will panic if any key or value in the
100 /// environment is not valid unicode. If this is not desired, consider using
101 /// [`env::vars_os()`].
108 /// // We will iterate through the references to the element returned by
110 /// for (key, value) in env::vars() {
111 /// println!("{}: {}", key, value);
115 /// [`env::vars_os()`]: vars_os
116 #[stable(feature = "env", since = "1.0.0")]
117 pub fn vars() -> Vars {
118 Vars { inner: vars_os() }
121 /// Returns an iterator of (variable, value) pairs of OS strings, for all the
122 /// environment variables of the current process.
124 /// The returned iterator contains a snapshot of the process's environment
125 /// variables at the time of this invocation. Modifications to environment
126 /// variables afterwards will not be reflected in the returned iterator.
128 /// Note that the returned iterator will not check if the environment variables
129 /// are valid Unicode. If you want to panic on invalid UTF-8,
130 /// use the [`vars`] function instead.
137 /// // We will iterate through the references to the element returned by
138 /// // env::vars_os();
139 /// for (key, value) in env::vars_os() {
140 /// println!("{:?}: {:?}", key, value);
143 #[stable(feature = "env", since = "1.0.0")]
144 pub fn vars_os() -> VarsOs {
145 VarsOs { inner: os_imp::env() }
148 #[stable(feature = "env", since = "1.0.0")]
149 impl Iterator for Vars {
150 type Item = (String, String);
151 fn next(&mut self) -> Option<(String, String)> {
152 self.inner.next().map(|(a, b)| (a.into_string().unwrap(), b.into_string().unwrap()))
154 fn size_hint(&self) -> (usize, Option<usize>) {
155 self.inner.size_hint()
159 #[stable(feature = "std_debug", since = "1.16.0")]
160 impl fmt::Debug for Vars {
161 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
162 f.debug_struct("Vars").finish_non_exhaustive()
166 #[stable(feature = "env", since = "1.0.0")]
167 impl Iterator for VarsOs {
168 type Item = (OsString, OsString);
169 fn next(&mut self) -> Option<(OsString, OsString)> {
172 fn size_hint(&self) -> (usize, Option<usize>) {
173 self.inner.size_hint()
177 #[stable(feature = "std_debug", since = "1.16.0")]
178 impl fmt::Debug for VarsOs {
179 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
180 f.debug_struct("VarOs").finish_non_exhaustive()
184 /// Fetches the environment variable `key` from the current process.
188 /// Errors if the environment variable is not present.
189 /// Errors if the environment variable is not valid Unicode. If this is not desired, consider using
194 /// This function may panic if `key` is empty, contains an ASCII equals sign
195 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
203 /// let key = "HOME";
204 /// match env::var(key) {
205 /// Ok(val) => println!("{}: {:?}", key, val),
206 /// Err(e) => println!("couldn't interpret {}: {}", key, e),
209 #[stable(feature = "env", since = "1.0.0")]
210 pub fn var<K: AsRef<OsStr>>(key: K) -> Result<String, VarError> {
214 fn _var(key: &OsStr) -> Result<String, VarError> {
216 Some(s) => s.into_string().map_err(VarError::NotUnicode),
217 None => Err(VarError::NotPresent),
221 /// Fetches the environment variable `key` from the current process, returning
222 /// [`None`] if the variable isn't set.
226 /// This function may panic if `key` is empty, contains an ASCII equals sign
227 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
230 /// Note that the method will not check if the environment variable
231 /// is valid Unicode. If you want to have an error on invalid UTF-8,
232 /// use the [`var`] function instead.
239 /// let key = "HOME";
240 /// match env::var_os(key) {
241 /// Some(val) => println!("{}: {:?}", key, val),
242 /// None => println!("{} is not defined in the environment.", key)
245 #[stable(feature = "env", since = "1.0.0")]
246 pub fn var_os<K: AsRef<OsStr>>(key: K) -> Option<OsString> {
247 _var_os(key.as_ref())
250 fn _var_os(key: &OsStr) -> Option<OsString> {
252 .unwrap_or_else(|e| panic!("failed to get environment variable `{:?}`: {}", key, e))
255 /// The error type for operations interacting with environment variables.
256 /// Possibly returned from [`env::var()`].
258 /// [`env::var()`]: var
259 #[derive(Debug, PartialEq, Eq, Clone)]
260 #[stable(feature = "env", since = "1.0.0")]
262 /// The specified environment variable was not present in the current
263 /// process's environment.
264 #[stable(feature = "env", since = "1.0.0")]
267 /// The specified environment variable was found, but it did not contain
268 /// valid unicode data. The found data is returned as a payload of this
270 #[stable(feature = "env", since = "1.0.0")]
271 NotUnicode(#[stable(feature = "env", since = "1.0.0")] OsString),
274 #[stable(feature = "env", since = "1.0.0")]
275 impl fmt::Display for VarError {
276 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
278 VarError::NotPresent => write!(f, "environment variable not found"),
279 VarError::NotUnicode(ref s) => {
280 write!(f, "environment variable was not valid unicode: {:?}", s)
286 #[stable(feature = "env", since = "1.0.0")]
287 impl Error for VarError {
289 fn description(&self) -> &str {
291 VarError::NotPresent => "environment variable not found",
292 VarError::NotUnicode(..) => "environment variable was not valid unicode",
297 /// Sets the environment variable `k` to the value `v` for the currently running
300 /// Note that while concurrent access to environment variables is safe in Rust,
301 /// some platforms only expose inherently unsafe non-threadsafe APIs for
302 /// inspecting the environment. As a result, extra care needs to be taken when
303 /// auditing calls to unsafe external FFI functions to ensure that any external
304 /// environment accesses are properly synchronized with accesses in Rust.
306 /// Discussion of this unsafety on Unix may be found in:
308 /// - [Austin Group Bugzilla](http://austingroupbugs.net/view.php?id=188)
309 /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
313 /// This function may panic if `key` is empty, contains an ASCII equals sign
314 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
323 /// env::set_var(key, "VALUE");
324 /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
326 #[stable(feature = "env", since = "1.0.0")]
327 pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
328 _set_var(key.as_ref(), value.as_ref())
331 fn _set_var(key: &OsStr, value: &OsStr) {
332 os_imp::setenv(key, value).unwrap_or_else(|e| {
333 panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e)
337 /// Removes an environment variable from the environment of the currently running process.
339 /// Note that while concurrent access to environment variables is safe in Rust,
340 /// some platforms only expose inherently unsafe non-threadsafe APIs for
341 /// inspecting the environment. As a result extra care needs to be taken when
342 /// auditing calls to unsafe external FFI functions to ensure that any external
343 /// environment accesses are properly synchronized with accesses in Rust.
345 /// Discussion of this unsafety on Unix may be found in:
347 /// - [Austin Group Bugzilla](http://austingroupbugs.net/view.php?id=188)
348 /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
352 /// This function may panic if `key` is empty, contains an ASCII equals sign
353 /// `'='` or the NUL character `'\0'`, or when the value contains the NUL
362 /// env::set_var(key, "VALUE");
363 /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
365 /// env::remove_var(key);
366 /// assert!(env::var(key).is_err());
368 #[stable(feature = "env", since = "1.0.0")]
369 pub fn remove_var<K: AsRef<OsStr>>(key: K) {
370 _remove_var(key.as_ref())
373 fn _remove_var(key: &OsStr) {
374 os_imp::unsetenv(key)
375 .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e))
378 /// An iterator that splits an environment variable into paths according to
379 /// platform-specific conventions.
381 /// The iterator element type is [`PathBuf`].
383 /// This structure is created by [`env::split_paths()`]. See its
384 /// documentation for more.
386 /// [`env::split_paths()`]: split_paths
387 #[stable(feature = "env", since = "1.0.0")]
388 pub struct SplitPaths<'a> {
389 inner: os_imp::SplitPaths<'a>,
392 /// Parses input according to platform conventions for the `PATH`
393 /// environment variable.
395 /// Returns an iterator over the paths contained in `unparsed`. The iterator
396 /// element type is [`PathBuf`].
403 /// let key = "PATH";
404 /// match env::var_os(key) {
406 /// for path in env::split_paths(&paths) {
407 /// println!("'{}'", path.display());
410 /// None => println!("{} is not defined in the environment.", key)
413 #[stable(feature = "env", since = "1.0.0")]
414 pub fn split_paths<T: AsRef<OsStr> + ?Sized>(unparsed: &T) -> SplitPaths<'_> {
415 SplitPaths { inner: os_imp::split_paths(unparsed.as_ref()) }
418 #[stable(feature = "env", since = "1.0.0")]
419 impl<'a> Iterator for SplitPaths<'a> {
421 fn next(&mut self) -> Option<PathBuf> {
424 fn size_hint(&self) -> (usize, Option<usize>) {
425 self.inner.size_hint()
429 #[stable(feature = "std_debug", since = "1.16.0")]
430 impl fmt::Debug for SplitPaths<'_> {
431 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
432 f.debug_struct("SplitPaths").finish_non_exhaustive()
436 /// The error type for operations on the `PATH` variable. Possibly returned from
437 /// [`env::join_paths()`].
439 /// [`env::join_paths()`]: join_paths
441 #[stable(feature = "env", since = "1.0.0")]
442 pub struct JoinPathsError {
443 inner: os_imp::JoinPathsError,
446 /// Joins a collection of [`Path`]s appropriately for the `PATH`
447 /// environment variable.
451 /// Returns an [`Err`] (containing an error message) if one of the input
452 /// [`Path`]s contains an invalid character for constructing the `PATH`
453 /// variable (a double quote on Windows or a colon on Unix).
457 /// Joining paths on a Unix-like platform:
461 /// use std::ffi::OsString;
462 /// use std::path::Path;
464 /// fn main() -> Result<(), env::JoinPathsError> {
465 /// # if cfg!(unix) {
466 /// let paths = [Path::new("/bin"), Path::new("/usr/bin")];
467 /// let path_os_string = env::join_paths(paths.iter())?;
468 /// assert_eq!(path_os_string, OsString::from("/bin:/usr/bin"));
474 /// Joining a path containing a colon on a Unix-like platform results in an
478 /// # if cfg!(unix) {
480 /// use std::path::Path;
482 /// let paths = [Path::new("/bin"), Path::new("/usr/bi:n")];
483 /// assert!(env::join_paths(paths.iter()).is_err());
487 /// Using `env::join_paths()` with [`env::split_paths()`] to append an item to
488 /// the `PATH` environment variable:
492 /// use std::path::PathBuf;
494 /// fn main() -> Result<(), env::JoinPathsError> {
495 /// if let Some(path) = env::var_os("PATH") {
496 /// let mut paths = env::split_paths(&path).collect::<Vec<_>>();
497 /// paths.push(PathBuf::from("/home/xyz/bin"));
498 /// let new_path = env::join_paths(paths)?;
499 /// env::set_var("PATH", &new_path);
506 /// [`env::split_paths()`]: split_paths
507 #[stable(feature = "env", since = "1.0.0")]
508 pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
510 I: IntoIterator<Item = T>,
513 os_imp::join_paths(paths.into_iter()).map_err(|e| JoinPathsError { inner: e })
516 #[stable(feature = "env", since = "1.0.0")]
517 impl fmt::Display for JoinPathsError {
518 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
523 #[stable(feature = "env", since = "1.0.0")]
524 impl Error for JoinPathsError {
525 #[allow(deprecated, deprecated_in_future)]
526 fn description(&self) -> &str {
527 self.inner.description()
531 /// Returns the path of the current user's home directory if known.
535 /// - Returns the value of the 'HOME' environment variable if it is set
536 /// (including to an empty string).
537 /// - Otherwise, it tries to determine the home directory by invoking the `getpwuid_r` function
538 /// using the UID of the current user. An empty home directory field returned from the
539 /// `getpwuid_r` function is considered to be a valid value.
540 /// - Returns `None` if the current user has no entry in the /etc/passwd file.
544 /// - Returns the value of the 'HOME' environment variable if it is set
545 /// (including to an empty string).
546 /// - Otherwise, returns the value of the 'USERPROFILE' environment variable if it is set
547 /// (including to an empty string).
548 /// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path.
550 /// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-getuserprofiledirectorya
557 /// match env::home_dir() {
558 /// Some(path) => println!("Your home directory, probably: {}", path.display()),
559 /// None => println!("Impossible to get your home dir!"),
564 reason = "This function's behavior is unexpected and probably not what you want. \
565 Consider using a crate from crates.io instead."
567 #[stable(feature = "env", since = "1.0.0")]
568 pub fn home_dir() -> Option<PathBuf> {
572 /// Returns the path of a temporary directory.
574 /// The temporary directory may be shared among users, or between processes
575 /// with different privileges; thus, the creation of any files or directories
576 /// in the temporary directory must use a secure method to create a uniquely
577 /// named file. Creating a file or directory with a fixed or predictable name
578 /// may result in "insecure temporary file" security vulnerabilities. Consider
579 /// using a crate that securely creates temporary files or directories.
583 /// Returns the value of the `TMPDIR` environment variable if it is
584 /// set, otherwise for non-Android it returns `/tmp`. If Android, since there
585 /// is no global temporary folder (it is usually allocated per-app), it returns
586 /// `/data/local/tmp`.
590 /// Returns the value of, in order, the `TMP`, `TEMP`,
591 /// `USERPROFILE` environment variable if any are set and not the empty
592 /// string. Otherwise, `temp_dir` returns the path of the Windows directory.
593 /// This behavior is identical to that of [`GetTempPath`][msdn], which this
594 /// function uses internally.
596 /// [msdn]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha
602 /// let mut dir = env::temp_dir();
603 /// println!("Temporary directory: {}", dir.display());
606 #[stable(feature = "env", since = "1.0.0")]
607 pub fn temp_dir() -> PathBuf {
611 /// Returns the full filesystem path of the current running executable.
613 /// # Platform-specific behavior
615 /// If the executable was invoked through a symbolic link, some platforms will
616 /// return the path of the symbolic link and other platforms will return the
617 /// path of the symbolic link’s target.
621 /// Acquiring the path of the current executable is a platform-specific operation
622 /// that can fail for a good number of reasons. Some errors can include, but not
623 /// be limited to, filesystem operations failing or general syscall failures.
627 /// The output of this function should not be used in anything that might have
628 /// security implications. For example:
632 /// println!("{:?}", std::env::current_exe());
636 /// On Linux systems, if this is compiled as `foo`:
641 /// Ok("/home/alex/foo")
644 /// And you make a hard link of the program:
650 /// When you run it, you won’t get the path of the original executable, you’ll
651 /// get the path of the hard link:
655 /// Ok("/home/alex/bar")
658 /// This sort of behavior has been known to [lead to privilege escalation] when
659 /// used incorrectly.
661 /// [lead to privilege escalation]: https://securityvulns.com/Wdocument183.html
668 /// match env::current_exe() {
669 /// Ok(exe_path) => println!("Path of this executable is: {}",
670 /// exe_path.display()),
671 /// Err(e) => println!("failed to get current exe path: {}", e),
674 #[stable(feature = "env", since = "1.0.0")]
675 pub fn current_exe() -> io::Result<PathBuf> {
676 os_imp::current_exe()
679 /// An iterator over the arguments of a process, yielding a [`String`] value for
682 /// This struct is created by [`env::args()`]. See its documentation
685 /// The first element is traditionally the path of the executable, but it can be
686 /// set to arbitrary text, and may not even exist. This means this property
687 /// should not be relied upon for security purposes.
689 /// [`env::args()`]: args
690 #[stable(feature = "env", since = "1.0.0")]
695 /// An iterator over the arguments of a process, yielding an [`OsString`] value
696 /// for each argument.
698 /// This struct is created by [`env::args_os()`]. See its documentation
701 /// The first element is traditionally the path of the executable, but it can be
702 /// set to arbitrary text, and may not even exist. This means this property
703 /// should not be relied upon for security purposes.
705 /// [`env::args_os()`]: args_os
706 #[stable(feature = "env", since = "1.0.0")]
708 inner: sys::args::Args,
711 /// Returns the arguments that this program was started with (normally passed
712 /// via the command line).
714 /// The first element is traditionally the path of the executable, but it can be
715 /// set to arbitrary text, and may not even exist. This means this property should
716 /// not be relied upon for security purposes.
718 /// On Unix systems the shell usually expands unquoted arguments with glob patterns
719 /// (such as `*` and `?`). On Windows this is not done, and such arguments are
722 /// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
723 /// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
724 /// extension. This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it
725 /// does on macOS and Windows.
729 /// The returned iterator will panic during iteration if any argument to the
730 /// process is not valid Unicode. If this is not desired,
731 /// use the [`args_os`] function instead.
738 /// // Prints each argument on a separate line
739 /// for argument in env::args() {
740 /// println!("{}", argument);
743 #[stable(feature = "env", since = "1.0.0")]
744 pub fn args() -> Args {
745 Args { inner: args_os() }
748 /// Returns the arguments that this program was started with (normally passed
749 /// via the command line).
751 /// The first element is traditionally the path of the executable, but it can be
752 /// set to arbitrary text, and may not even exist. This means this property should
753 /// not be relied upon for security purposes.
755 /// On Unix systems the shell usually expands unquoted arguments with glob patterns
756 /// (such as `*` and `?`). On Windows this is not done, and such arguments are
759 /// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`.
760 /// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard
761 /// extension. This allows `std::env::args_os` to work even in a `cdylib` or `staticlib`, as it
762 /// does on macOS and Windows.
764 /// Note that the returned iterator will not check if the arguments to the
765 /// process are valid Unicode. If you want to panic on invalid UTF-8,
766 /// use the [`args`] function instead.
773 /// // Prints each argument on a separate line
774 /// for argument in env::args_os() {
775 /// println!("{:?}", argument);
778 #[stable(feature = "env", since = "1.0.0")]
779 pub fn args_os() -> ArgsOs {
780 ArgsOs { inner: sys::args::args() }
783 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
784 impl !Send for Args {}
786 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
787 impl !Sync for Args {}
789 #[stable(feature = "env", since = "1.0.0")]
790 impl Iterator for Args {
792 fn next(&mut self) -> Option<String> {
793 self.inner.next().map(|s| s.into_string().unwrap())
795 fn size_hint(&self) -> (usize, Option<usize>) {
796 self.inner.size_hint()
800 #[stable(feature = "env", since = "1.0.0")]
801 impl ExactSizeIterator for Args {
802 fn len(&self) -> usize {
805 fn is_empty(&self) -> bool {
806 self.inner.is_empty()
810 #[stable(feature = "env_iterators", since = "1.12.0")]
811 impl DoubleEndedIterator for Args {
812 fn next_back(&mut self) -> Option<String> {
813 self.inner.next_back().map(|s| s.into_string().unwrap())
817 #[stable(feature = "std_debug", since = "1.16.0")]
818 impl fmt::Debug for Args {
819 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
820 f.debug_struct("Args").field("inner", &self.inner.inner).finish()
824 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
825 impl !Send for ArgsOs {}
827 #[stable(feature = "env_unimpl_send_sync", since = "1.26.0")]
828 impl !Sync for ArgsOs {}
830 #[stable(feature = "env", since = "1.0.0")]
831 impl Iterator for ArgsOs {
832 type Item = OsString;
833 fn next(&mut self) -> Option<OsString> {
836 fn size_hint(&self) -> (usize, Option<usize>) {
837 self.inner.size_hint()
841 #[stable(feature = "env", since = "1.0.0")]
842 impl ExactSizeIterator for ArgsOs {
843 fn len(&self) -> usize {
846 fn is_empty(&self) -> bool {
847 self.inner.is_empty()
851 #[stable(feature = "env_iterators", since = "1.12.0")]
852 impl DoubleEndedIterator for ArgsOs {
853 fn next_back(&mut self) -> Option<OsString> {
854 self.inner.next_back()
858 #[stable(feature = "std_debug", since = "1.16.0")]
859 impl fmt::Debug for ArgsOs {
860 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
861 f.debug_struct("ArgsOs").field("inner", &self.inner).finish()
865 /// Constants associated with the current target
866 #[stable(feature = "env", since = "1.0.0")]
868 use crate::sys::env::os;
870 /// A string describing the architecture of the CPU that is currently
873 /// Some possible values:
886 #[stable(feature = "env", since = "1.0.0")]
887 pub const ARCH: &str = env!("STD_ENV_ARCH");
889 /// The family of the operating system. Example value is `unix`.
891 /// Some possible values:
895 #[stable(feature = "env", since = "1.0.0")]
896 pub const FAMILY: &str = os::FAMILY;
898 /// A string describing the specific operating system in use.
899 /// Example value is `linux`.
901 /// Some possible values:
913 #[stable(feature = "env", since = "1.0.0")]
914 pub const OS: &str = os::OS;
916 /// Specifies the filename prefix used for shared libraries on this
917 /// platform. Example value is `lib`.
919 /// Some possible values:
922 /// - `""` (an empty string)
923 #[stable(feature = "env", since = "1.0.0")]
924 pub const DLL_PREFIX: &str = os::DLL_PREFIX;
926 /// Specifies the filename suffix used for shared libraries on this
927 /// platform. Example value is `.so`.
929 /// Some possible values:
934 #[stable(feature = "env", since = "1.0.0")]
935 pub const DLL_SUFFIX: &str = os::DLL_SUFFIX;
937 /// Specifies the file extension used for shared libraries on this
938 /// platform that goes after the dot. Example value is `so`.
940 /// Some possible values:
945 #[stable(feature = "env", since = "1.0.0")]
946 pub const DLL_EXTENSION: &str = os::DLL_EXTENSION;
948 /// Specifies the filename suffix used for executable binaries on this
949 /// platform. Example value is `.exe`.
951 /// Some possible values:
956 /// - `""` (an empty string)
957 #[stable(feature = "env", since = "1.0.0")]
958 pub const EXE_SUFFIX: &str = os::EXE_SUFFIX;
960 /// Specifies the file extension, if any, used for executable binaries
961 /// on this platform. Example value is `exe`.
963 /// Some possible values:
966 /// - `""` (an empty string)
967 #[stable(feature = "env", since = "1.0.0")]
968 pub const EXE_EXTENSION: &str = os::EXE_EXTENSION;