mise icon indicating copy to clipboard operation
mise copied to clipboard

mise task `file` is not useable from subdirectory

Open chronicc opened this issue 11 months ago • 2 comments

Describe the bug

[settings]
experimental = true

[tasks.kubernetes-up]
description = "Start a local Kubernetes cluster"
file = "kubernetes/k8s-start-cluster.sh"
# directory layout

+ project_root/
  + kubernetes/
    + k8s-start-cluster.sh
  + minikube/

I have a subdirectory kubernetes in which the script file k8s-start-cluster.sh is located. When I run mise run kubernetes-up from the project root, the script is successfully executed. When I run the same mise call from the minikube directory, the script file is not found as the path starts inside of the subdirectory instead of the project root.

To Reproduce

  • Create directory structure and mise config as described above.
  • Run mise run kubernetes-up from project root -> success
  • Run mise run kubernetes-up from minikube subdirectory -> fail

Expected behavior Mise tasks should be able to run from any subdirectory.

mise doctor output

version: 2024.2.18 linux-x64 (4893e09 2024-02-24)
activated: yes
shims_on_path: no

build_info: 
  Target: x86_64-unknown-linux-gnu
  Features: DEFAULT, NATIVE_TLS, OPENSSL
  Built: Sat, 24 Feb 2024 06:33:38 +0000
  Rust Version: rustc 1.76.0 (07dca489a 2024-02-04)
  Profile: release

shell: 
  /bin/bash
  GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
  Copyright (C) 2020 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software; you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

dirs: 
  data: ~/.local/share/mise
  config: ~/.config/mise
  cache: ~/.cache/mise
  state: ~/.local/state/mise
  shims: ~/.local/share/mise/shims

config_files: 
  ~/.config/mise/config.toml
  ~/git/chronicc/eval/.mise.toml

plugins: 
  awscli      https://github.com/MetricMike/asdf-awscli.git#2e31396
  bun         (core)
  deno        (core)
  erlang      (core)
  go          (core)
  helm        https://github.com/Antiarchitect/asdf-helm.git#a39e17b
  java        (core)
  jq          https://github.com/lsanwick/asdf-jq.git#addae51
  k9s         https://github.com/looztra/asdf-k9s.git#2b3af87
  kubectl     https://github.com/asdf-community/asdf-kubectl.git#cbe6df4
  minikube    https://github.com/alvarobp/asdf-minikube.git#a6adc7b
  node        (core)
  poetry      https://github.com/rtx-plugins/rtx-poetry.git#82d11e3
  pulumi      https://github.com/canha/asdf-pulumi.git#99d675b
  python      (core)
  ruby        (core)
  shellcheck  https://github.com/luizm/asdf-shellcheck.git#780d78d
  shfmt       https://github.com/luizm/asdf-shfmt.git#a42c5ff
  tilt        https://github.com/eaceaser/asdf-tilt.git#69eac7b
  tiny        https://github.com/rtx-plugins/rtx-tiny.git#c532b14
  usage       https://github.com/jdx/mise-usage.git#fe3888a

toolset: 
  [email protected]   
  [email protected]  
  [email protected]   
  [email protected]    
  [email protected]     
  [email protected]     (missing)
  [email protected]       
  [email protected]      
  [email protected]      
  [email protected]       
  [email protected]   
  [email protected]      

env_vars: 
  MISE_SHELL=bash

settings: 
  activate_aggressive = false
  all_compile = false
  always_keep_download = false
  always_keep_install = false
  asdf_compat = false
  cargo_binstall = true
  color = true
  disable_default_shorthands = false
  disable_tools = []
  experimental = true
  go_default_packages_file = "~/.default-go-packages"
  go_download_mirror = "https://dl.google.com/go"
  go_repo = "https://github.com/golang/go"
  go_set_gopath = false
  go_set_goroot = true
  go_skip_checksum = false
  jobs = 4
  legacy_version_file = true
  legacy_version_file_disable_tools = []
  node_compile = false
  not_found_auto_install = true
  paranoid = false
  plugin_autoupdate_last_check_duration = "7d"
  python_compile = false
  python_default_packages_file = "/home/chronicc/.default-python-packages"
  python_pyenv_repo = "https://github.com/pyenv/pyenv.git"
  raw = false
  trusted_config_paths = []
  quiet = false
  verbose = false
  yes = false
  ci = false
  debug = false
  trace = false
  log_level = "info"
  python_venv_auto_create = false

  [status]
  missing_tools = "if_other_versions_installed"
  show_env = false
  show_tools = false

No problems found

Additional context

I've also tried using the explicit relative path:

[tasks.kubernetes-up]
description = "Start a local Kubernetes cluster"
file = "./kubernetes/k8s-start-cluster.sh"

chronicc avatar Feb 26 '24 14:02 chronicc

I've also tried to using the templating feature with no success.

[tasks.kubernetes-up]
description = "Start a local Kubernetes cluster"
file = "{{ config_root }}/kubernetes/k8s-start-cluster.sh"

Outcome

minikube$ mise run
 Tasks kubernetes-up
 Script `{{ config_root }}/kubernetes/k8s-start-cluster.sh` is not executable. Make it executable?

chronicc avatar Feb 27 '24 13:02 chronicc

was running into the same issue, even tried with setting dir with no luck.

however seems like a workaround is to use the tasks dir setup.

directory layout:

sample
├── .mise
│  ├── config.toml
│  └── tasks
│     └── echo
└── nested_dir

content of echo script (needs to be executable)

#!/usr/bin/env bash
# mise dir="{{config_root}}"

echo "hello world"

this seems to work from the root & nested dir

# from project root
sample$ mise run echo
hello world

# from nested dir
nested_dir$ mise run echo
hello world

not ideal since now would need to have files for each task rather than defining them in the config.toml but could unblock some folks

jatinn avatar Mar 08 '24 01:03 jatinn