Skip to content

Absolute paths #1348

@carymrobbins

Description

@carymrobbins

Compiler messages will only display the relative path to source files from their respective packages (except in one case). For instance, if I check out the stack-ide project and update stack-ide/src/main/Main.hs with some uncompilable code, I'll get the following error -

    src/main/Main.hs:27:7:
        Couldn't match type ‘Int’ with ‘[Char]’
        Expected type: String
          Actual type: Int
        In the expression: 1.0 :: Int
        In an equation for ‘foo’: foo = 1.0 :: Int

This is, of course, relative to the stack-ide package. However, if I am consuming stack's output from another process, there is no clear, unambiguous way for it to determine where this source file actually resides. Ideally, if the paths that were configured to be absolute, this would not be an issue.

One workaround is to cd into the package directory and then run stack build .; stack then seems to report the absolute path. This is far from ideal, though, since it means you'd have to do this separately for each package, making the process inefficient.

Is there a way to have stack reliably produce absolute paths? If it could at least report out the absolute path to the package it is building before reporting messages, that would give the consumer process a consistent and efficient way to determine where the source file resides.

Some additional context - I am working on providing users of HaskForce the ability to build their projects with stack. It is consuming output from stack build and needs to be able to jump the user directly to the source locations from compiler messages. I'd like to be able to consume the output directly from stack to avoid forcing users to configure additional tools.

There may be a better or simpler way to determine the absolute paths to the source files, so I am open to any solutions.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions