fast-nail-55400
10/25/2024, 12:00 PMproud-dentist-22844
10/25/2024, 3:13 PM.git/modules directory (an admittedly questionable thing to do). One quirk I've noticed is that I get a warning when I run pants lint :: about linting my shell_command target, but why would that target need to be linted? Does it run shellcheck on the command? If so, we might want 2 environment fields, one for running the command and another for linting it. Because linting does not need to run in the workspace, and I would rather it didn't.
Oh, I could probably skip lint on that target. You might want to add a limitation note about how the environment will be used for all goals including running, pointing, etc.fast-nail-55400
10/27/2024, 1:27 AMYou might want to add a limitation note about how the environment will be used for all goals including running, linting, etc.I was not aware linting ran on
shell_command targets. The better solution would seem to be your suggestion of two targets: one for "execution" and one for (for lack of a batter term) "non-execution"fast-nail-55400
10/27/2024, 1:30 AMshell_sources in the same directory as the shell_command target? Maybe you have a shell script being picked up that way? (Looking at the shellcheck rules, it registers only for shell_source and shunit2_test target types.)fast-nail-55400
10/27/2024, 1:44 AMShellCommandSourcesField private field called _sources which I wonder if it has some relevance or not.proud-dentist-22844
10/27/2024, 1:49 AMshell_sources target in the same BUILD file, but when I run pants lint :: the warning specifically mentions the `shell_command`'s address:
20:38:50.07 [WARN] The lint goal was called with target `//:capture_git_modules`, which specifies the environment `in_repo_workspace`, which is a `experimental_workspace_environment`. The lint goal only runs in the local environment. You may experience unexpected behavior.
You can see that target here:
https://github.com/StackStorm/st2/blob/master/BUILD#L105-L120
And the environment definition here:
https://github.com/StackStorm/st2/blob/master/BUILD.environment#L10-L23
Oh. The visibility backend lints all targets. I guessed wrong, shellcheck is not linting the shell_command.
$ pants lint //:capture_git_modules
20:48:02.55 [WARN] The lint goal was called with target `//:capture_git_modules`, which specifies the environment `in_repo_workspace`, which is a `experimental_workspace_environment`. The lint goal only runs in the local environment. You may experience unexpected behavior.
20:48:02.79 [INFO] Completed: Check for visibility rule violations - visibility succeeded.
✓ visibility succeeded.proud-dentist-22844
10/27/2024, 1:54 AMfast-nail-55400
10/27/2024, 2:04 AMEnvironmentTarget has some helpers for rules to use to know when a target is “local”.proud-dentist-22844
10/27/2024, 2:05 AMfast-nail-55400
10/27/2024, 2:05 AMfast-nail-55400
10/27/2024, 2:07 AMcan_use_system_path_metadata_requestsproud-dentist-22844
10/27/2024, 2:08 AMisinstance check to determine if its local: isinstance(env_tgt.val, LocalEnvironmentTarget)
https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/util_rules/environments.py#L485fast-nail-55400
10/27/2024, 2:09 AMfast-nail-55400
10/27/2024, 2:16 AMisinstance check.proud-dentist-22844
10/27/2024, 2:16 AMEnvironmentTarget that works just like can_use_system_path_metadata_requests, maybe called is_local_compatible?proud-dentist-22844
10/27/2024, 2:18 AM$ git grep 'isinstance([^,]*, LocalEnvironmentTarget)'
src/python/pants/core/util_rules/adhoc_binaries.py: if env_tgt.val is None or isinstance(env_tgt.val, LocalEnvironmentTarget):
src/python/pants/core/util_rules/asdf.py: if not (isinstance(env_tgt.val, LocalEnvironmentTarget) or env_tgt.val is None):
src/python/pants/core/util_rules/environments.py: if env_tgt.val is not None and not isinstance(env_tgt.val, LocalEnvironmentTarget)
src/python/pants/core/util_rules/search_paths.py: if not (request.env_tgt.val is None or isinstance(request.env_tgt.val, LocalEnvironmentTarget)):
src/python/pants/core/util_rules/search_paths.py: if env is None or isinstance(env, LocalEnvironmentTarget):proud-dentist-22844
10/27/2024, 2:25 AMfast-nail-55400
10/27/2024, 2:31 AMsrc/python/pants/core/util_rules/adhoc_binaries.py:52 -- Checks whether a Python executable is available "locally" to the rule code (so available directly and not, for example, running in a Docker container)
• src/python/pants/core/util_rules/environments.py:485 -- _warn_on_non_local_environments function which checks whether the environment is "non-local". It is a helper used in other parts of the code to check for non-local environments. (Visibility rules should probably use it.)
• src/python/pants/core/util_rules/search_paths.py:54 -- Checks to see if paths for a "versions manager" like pyenv are available locally.
• src/python/pants/core/util_rules/search_paths.py:124 -- Similar check whether discovered paths can only be discovered locally.
• src/python/pants/core/util_rules/asdf.py:100 -- Another check whether ASDF-discovered paths can be directly accessed in the current environment. (If not available locally, the ASDF provider just reports no paths.)fast-nail-55400
10/27/2024, 2:32 AMproud-dentist-22844
10/27/2024, 2:32 AM_warn_on_non_local_environment, but that method gets called for all lint backends in the base code.fast-nail-55400
10/27/2024, 2:33 AMThe visibility backend is a lint backend. It does not directly callAh so the warning you saw probably originated there?, but that method gets called for all lint backends in the base code._warn_on_non_local_environment
proud-dentist-22844
10/27/2024, 2:33 AMcan_use_system_path_metadata_requests name. I assumed that SystemPathMetadataRequest was a specific dataclass request as input for some specific rule.proud-dentist-22844
10/27/2024, 2:34 AMThis is where the warning gets raised:
https://github.com/pantsbuild/pants/blob/main/src/python/pants/core/goals/lint.py#L367
fast-nail-55400
10/27/2024, 2:35 AMcan_use_system_path_metadata_requests just means that the PathNamespace.SYSTEM can be used with PathMetadataRequestproud-dentist-22844
10/27/2024, 2:36 AMfast-nail-55400
10/27/2024, 2:37 AMPathMetadataRequestproud-dentist-22844
10/27/2024, 2:37 AMcan_use_system_paths overly generic?fast-nail-55400
10/27/2024, 2:38 AMsupports_direct_client_access_to_files_in_environmentfast-nail-55400
10/27/2024, 2:38 AMproud-dentist-22844
10/27/2024, 2:39 AMcan_use_client_system_paths?
can_use_pants_client_system_paths?fast-nail-55400
10/27/2024, 2:39 AMproud-dentist-22844
10/27/2024, 2:40 AMcan_use_local_system_pathsproud-dentist-22844
10/27/2024, 2:41 AMfast-nail-55400
10/27/2024, 2:46 AMfast-nail-55400
10/27/2024, 2:46 AMfast-nail-55400
10/29/2024, 8:19 AM