why i got error while launching stack build?

443 Views Asked by At

I am new in haskell programming. For my university project our teacher send us the project and ask us to run these command : "stack init" then "stack build" when i am running stack build a got this error :

Project.cabal was modified manually. Ignoring Project\package.yaml in favor of the Cabal file.
If you want to use the package.yaml file instead of the Cabal file,
then please delete the Cabal file.
Executable named sh not found on path: ....."Path"

Can anyone help solve the problem please ?

remove all project and try again .

2

There are 2 best solutions below

0
Martin Baulig On

In general, stack init is only run once to initialize a new project. You would typically run this in an empty directory, where it will create a stack.yaml from some template.

This template stack.yaml mostly contains comments that explain you all the different options.

However, you could also manually create it, like for instance:

resolver: lts-20.16

Once you have your stack.yaml in place, there are two options:

You can either use a traditional <your-project-name>.cabal file, or write a package.yaml file. See https://github.com/sol/hpack for details on how to write such a file.

When you use stack build, and there is only a .cabal file and no package.yaml, then Stack will use that.

However, if a package.yaml exists, then Stack will automatically create and update the <your-project-name>.cabal file for you.

And prior to doing so, it will check whether that file is newer than the stack.yaml or package.yaml, to avoid possibly overwriting any manual changes in that file.

So the error message that you're getting should normally mean that someboy (ie. your teacher) manually edited the Project.cabal file although a package.yaml exists.

However, what is puzzling about it is that normally, both files should be in the project's root directory - but your error message contains a Windows-style path-name in it.

Then, there is the ever more troubling last line - about sh not found on path.

Is it possible that you are trying to run this on Windows?

I have never used Haskell on Windows myself, so I have no clue about how that should work. But an error message about the Linux / Unix command interpreter sh not being found would be typical for some Linux / Unix software that's not been fully ported to Windows yet.

I am also solely basing my "Windows suspicion" on the first line of the error message, which contains a path with a backslash in it, as it would on Windows.

But maybe my general description of the Stack build process can help shed some light on this as well.

0
tept_23 On

Had the same issue with a fresh GHCup install on Windows 10.

    Executable named sh not found on path: ~entire windows path variable~

For some reason GHCup doesn't add msys to the path on install, which contains sh.exe.

Assuming default install options, add the following to the "Path" user environment variable through the windows dialogue:

    C:\ghcup\msys64\usr\bin

Solution found by reading about an old Stack bug here.