New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute paths #1348

Closed
carymrobbins opened this Issue Nov 16, 2015 · 6 comments

Comments

Projects
None yet
3 participants
@carymrobbins

carymrobbins commented Nov 16, 2015

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.

@mgsloan mgsloan added this to the P2: Should milestone Nov 16, 2015

@borsboom

This comment has been minimized.

Contributor

borsboom commented Nov 18, 2015

This looks like a duplicate of #1259, which is fixed in master. Can you
try this with the latest master stack?

On Sun, Nov 15, 2015 at 6:28 PM Cary Robbins notifications@github.com
wrote:

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
https://github.com/carymrobbins/intellij-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.


Reply to this email directly or view it on GitHub
#1348.

@carymrobbins

This comment has been minimized.

carymrobbins commented Nov 18, 2015

@borsboom - I have the same issue with the master build. Doing stack build (even with the --pedantic flag I saw in your referenced ticket) still produces paths relative to the respective package.

@borsboom

This comment has been minimized.

Contributor

borsboom commented Nov 22, 2015

Thanks, I was able to reproduce this using the stack-ide repo as well. The problems appears to be that the paths output by GHC are canonicalized to absolute paths when Stack is directly passing GHC's output to the console, but not when it dumps the log after a build failure. That means if you're only building a single package, the paths do get canonicalized (e.g. try stack build stack-ide), but if there are many packages to build, they do not.

@borsboom borsboom modified the milestones: P1: Must, P2: Should Nov 22, 2015

@borsboom borsboom self-assigned this Nov 22, 2015

@borsboom borsboom closed this in a4fdeae Nov 27, 2015

@borsboom

This comment has been minimized.

Contributor

borsboom commented Nov 27, 2015

Fixed on master branch.

@carymrobbins

This comment has been minimized.

carymrobbins commented Nov 27, 2015

Awesome! Looking forward to testing it. Nice work!

@carymrobbins

This comment has been minimized.

carymrobbins commented Nov 28, 2015

Confirmed, this works as expected. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment