Navigation Menu

Skip to content
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
Closed

Absolute paths #1348

carymrobbins opened this issue Nov 16, 2015 · 6 comments
Assignees
Milestone

Comments

@carymrobbins
Copy link

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
Copy link
Contributor

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
Copy link
Author

@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
Copy link
Contributor

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
Copy link
Contributor

Fixed on master branch.

@carymrobbins
Copy link
Author

Awesome! Looking forward to testing it. Nice work!

@carymrobbins
Copy link
Author

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
Projects
None yet
Development

No branches or pull requests

3 participants