Skip to content

Absolute paths in replace key in manifest file don't work #2857

@aleasims

Description

@aleasims

What's your CLI version?

1.14.1

Description & steps to reproduce

When I replace a package with an absolute local path and run enclave with kurtosis run ., I get an error like stat home/user/my-package: no such file or directory (notice the missing / at the beginning). Instead of searching for /home/user/my-package, Kurtosis searches for home/user/my-package and fails.

As far as I can tell from docs, absolute paths should be supported:

To support this use case, the value of a replace line can be an absolute or relative path on your local filesystem to a Kurtosis package (a directory containing a kurtosis.yml file).

For example:

name: github.com/mieubrisse/my-package

replace:
    # Replace the official Postgres package with the version on my filesystem (relative import)
    github.com/kurtosis-tech/postgres-package: ../postgres-package

    # Replace the official MongoDB package with the version on my filesystem (absolute import)
    github.com/kurtosis-tech/mongodb-package: /home/code/mongodb-package

Reproduce

  1. Create following structure:
/tmp/
├── pkg1/
│   ├── main.star
│   └── kurtosis.yml
└── pkg2/
    ├── main.star
    └── kurtosis.yml
  1. Content of pkg1:
# /tmp/pkg1/kurtosis.yml
name: github.com/user/pkg1
replace: {}
# /tmp/pkg1/main.star
def run(plan):
    plan.print("hello from pkg1")
  1. Content of pkg2:
# /tmp/pkg2/kurtosis.yml
name: github.com/user/pkg2
replace:
    github.com/user/pkg1: /tmp/pkg1
# /tmp/pkg2/main.star
pkg1 = import_module("github.com/user/pkg1/main.star")

def run(plan):
    pkg1.run(plan)
    plan.print("hello from pkg2")
  1. Running enclave
kurtosis run /tmp/pkg2

Expected output

...
Printing a message
hello from pkg1

Printing a message
hello from pkg2
...

Actual result

Error:  An error occurred running command 'run'
  Caused by: An error occurred calling the run function for command 'run'
  Caused by: An error starting the Kurtosis code execution '/tmp/pkg2'
  Caused by: An error occurred while uploading the local starlark package dependencies from the replace options 'map[github.com/user/pkg1:/tmp/pkg1]'
  Caused by: Error uploading package '/tmp/pkg1' prior to executing it
  Caused by: There was an error compressing module '/tmp/pkg2/tmp/pkg1' before upload
  Caused by: An error occurred creating the archive from the files at '/tmp/pkg2/tmp/pkg1'
  Caused by: There was an error in getting a list of files in the directory '/tmp/pkg2/tmp/pkg1' provided
  Caused by: Error listing files in '/tmp/pkg2/tmp/pkg1'
  Caused by: There was a path error for '/tmp/pkg2/tmp/pkg1'.
  Caused by: stat /tmp/pkg2/tmp/pkg1: no such file or directory

What happens

If I'm not mistaken, the actual bug is in uploadLocalStarlarkPackageDependencies function:

localPackagePath := path.Join(packageRootPath, replaceOption)

path.Join() is called with two paths e.g. /tmp/pkg1 and /tmp/pkg2, which results into /tmp/pkg2/tmp/pkg1. Instead, if the replaceOption is absolute, there must be no path joining.

Suggested fix:

localPackagePath := replaceOption
if !path.IsAbs(localPackagePath) {
	localPackagePath = path.Join(packageRootPath, localPackagePath)
}
...

Desired behavior

Kurtosis resolves absolute paths properly.

What is the severity of this bug?

Painful; this is causing significant friction in my workflow.

What area of the product does this pertain to?

CLI: the Command Line Interface

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliFor bugs relating to the CLIpainfulPainful bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions