Skip to content

Default working directory for forked vs non-forked runs/tests are different #3892

@er1c

Description

@er1c

Issue

The default working directory changes when fork := true, is specified.

Example command: sbt "project subproject" "runMain foo.foo.App"

Non fork:

Uses the top-level project directory as the working directory.

With fork in Test := true,:

Uses the subproject directory as the working directory.

Expectation

I would expect the default behavior to be consistent.

sbt version: 1.1.0


Original ticket for referencing conversation thread

I have a multi-project sbt file that I recently added the fork in (Compile, run) := true option on.

One of the first issues that popped up was the process wouldn't read a local file "localdir/localfiles.txt" - basically the working directory wasn't set to the project directory. This was easily fixed by manually specifying a working directory such as baseDirectory in (Compile, run) := file(".")

I would expect this to be a default behavior, rather than needing to be explicit. IntelliJ recently (in the last year or two?) also added a "Use project home as compile server working directory" which is the same/similar behavior I would expect.

an sbt "project subproject" "runMain foo.foo.App" will also use the top-level directory as the working directory

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions