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

Support docker integration on Windows #5315

Conversation

gdziadkiewicz
Copy link
Contributor

@gdziadkiewicz gdziadkiewicz commented Jun 9, 2020

Fixes #2421

Note: Documentation fixes for https://docs.haskellstack.org/en/stable/ should target the "stable" branch, not master.

Please include the following checklist in your PR:

  • Any changes that could be relevant to users have been recorded in the ChangeLog.md
  • The documentation has been updated, if necessary.

Please also shortly describe how you tested your change. Bonus points for added tests!

What did I do?

I added function transforming Windows paths to Linux paths and applied it places in which the path needs to be in Linux style (because it's a path inside the container).

How did I test it?

I ran stack --docker ghci, stack --docker build, stack --docker test for https://github.com/BNFC/bnfc with and without STACK_YAML on my Windows 10 + Docker for Windows (wsl2 engine) machine.

@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from b49f6d3 to bbda3b1 Compare June 19, 2020 00:42
@gdziadkiewicz gdziadkiewicz changed the title #2421 support docker integration on windows Support docker integration on windows Jun 21, 2020
@gdziadkiewicz gdziadkiewicz changed the title Support docker integration on windows Support docker integration on Windows Jun 21, 2020
@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from 858ec93 to d1f6289 Compare June 21, 2020 15:03
@gdziadkiewicz gdziadkiewicz marked this pull request as ready for review June 21, 2020 15:48
@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from d1f6289 to 352faf1 Compare July 19, 2020 13:38
@gdziadkiewicz
Copy link
Contributor Author

I added ChangeLog entry and rebased the fix to master. From my PoV this is ready for review. Is there something else that I need to provide in order to get this merged?

@Michiel-s
Copy link

Hi @gdziadkiewicz and Haskell community, any update on when we might expect this feature/fix for Windows? I really would like this thing to happen, because our open source team wants to start working with dev containers. Most of us use a Windows machine with Docker.

Thx for making the effort!

I haven’t been able to test this PR myself. @hanjoosten, have you?

@hanjoosten
Copy link

Not really sure how to test this, but this is what I did, and what the result was:

  1. I pulled this branch, and then I ran stack install.
  2. I ran stack --docker ghci, which failed, because of a missing release v2.4.0. (which seems reasonable, because that doesn't exist yet):
D:\git\stack>stack --docker ghci
Pulling image from registry: 'fpco/alpine-haskell-stack@sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba'
sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba: Pulling from fpco/alpine-haskell-stack
c9b1b535fdd9: Already exists                                                                                            fc3117333f24: Pull complete                                                                                             83ac254ba7e6: Pull complete                                                                                             05ee1662922d: Pull complete                                                                                             d442adc40279: Pull complete                                                                                             893ef3fd456a: Pull complete                                                                                             Digest: sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba
Status: Downloaded newer image for fpco/alpine-haskell-stack@sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba
docker.io/fpco/alpine-haskell-stack@sha256:49e7e15f3b1d3f882ba5bb701463b1d508fbf40e5aafce6ea31acd210da570ba
Downloading Docker-compatible stack executable
Control.Exception.Safe.throwString called with:

Could not get release information for Stack from: https://api.github.com/repos/commercialhaskell/stack/releases/tags/v2.4.0
Called from:
  throwString (src/Stack\Setup.hs:1813:14 in stack-2.4.0-OskankWTJK8NOSddLAL0W:Stack.Setup)


D:\git\stack>

@gdziadkiewicz
Copy link
Contributor Author

Hi @hanjoosten , to test it locally I changed version number in stack.cabal to the previous, existing one (ATM it's version: 2.3.1) as mentioned in the comment in #2421 .

@gdziadkiewicz
Copy link
Contributor Author

@Michiel-s Form my PoV this is ready to be reviewed and merged. @snoyberg could you please help with progressing this?

@hanjoosten
Copy link

Hmm. I ran into a probably unrelated issue, building one of the dependancies.
I faintly remember having problems with hourglass before at some point.

<skipped initial lines of log>
hourglass             > [15 of 17] Compiling Data.Hourglass
hourglass             > [16 of 17] Compiling Time.Compat
hourglass             > [17 of 17] Compiling Data.Hourglass.Compat
memory                > Registering library for memory-0.14.18..
hourglass             >
hourglass             > copy/register
hourglass             > Installing library in /C/sr/snapshots/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/7f3ea4ceb819c0da37dac241d480b3cf5293ed68b88e9747ca8a9b21569136a9/8.6.5/lib/x86_64-linux-ghc-8.6.5/hourglass-0.2.12-333qxqQQ3eK9Jo0nKcpgW5
hourglass             > /usr/bin/strip:/C/sr/snapshots/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/7f3ea4ceb819c0da37dac241d480b3cf5293ed68b88e9747ca8a9b21569136a9/8.6.5/lib/x86_64-linux-ghc-8.6.5/hourglass-0.2.12-333qxqQQ3eK9Jo0nKcpgW5/stepKkHM/unix.o: File exists
mime-types            > copy/register
mime-types            > Installing library in /C/sr/snapshots/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/7f3ea4ceb819c0da37dac241d480b3cf5293ed68b88e9747ca8a9b21569136a9/8.6.5/lib/x86_64-linux-ghc-8.6.5/mime-types-0.1.0.9-IuKFWuzgmF26e9nOlDWqrD
mime-types            > Registering library for mime-types-0.1.0.9..

Error: 'cabal copy' failed.  Error message:

--  While building package hourglass-0.2.12 using:
      /C/sr/setup-exe-cache/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-2.4.0.1 copy
    Process exited with code: ExitFailure 1

Possible causes of this issue:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
* A cabal file that refers to nonexistent other files (e.g. a license-file that doesn't exist). Running 'cabal check' may point out these issues.


'cabal copy' failed.  Error message:

--  While building package ed25519-0.0.5.0 using:
      /C/sr/setup-exe-cache/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-2.4.0.1 copy
    Process exited with code: ExitFailure 1

Possible causes of this issue:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.
* A cabal file that refers to nonexistent other files (e.g. a license-file that doesn't exist). Running 'cabal check' may point out these issues.


Warning: Build failed, but trying to launch GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: stack

Warning: Didn't find expected autogen file:
         /D/git/stack/.stack-work/dist/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-2.4.0.1/build/autogen/cabal_macros.h

Warning: Didn't find expected autogen file:
         /D/git/stack/.stack-work/dist/x86_64-linux-dk4f31dc93c12465b48238129ec7324625/Cabal-2.4.0.1/build/stack/autogen/cabal_macros.h
Progress 10/133GHCi, version 8.6.5: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package Cabal-3.0.0.0
    (use -v for more information)

D:\git\stack>

@gdziadkiewicz
Copy link
Contributor Author

@hanjoosten I will try to reproduce and investigate. Could you share more information about your environment? Things that I'm especially interested in are your:

  • os version
  • partitions (do I understand correctly from the logs that your Stack installation is on C drive and the Stack repo you are trying to build is on D drive?)
  • Docker configuration (do you use Docker for Windows, remote Docker server or something else?)

@hanjoosten
Copy link

@gdziadkiewicz , sorry for the late reply. I am very busy with other stuff these days.

  • os version: Windows 10, version 1909 (build 18363.959) (Dutch language)
  • The local harddrive has two partitions, C and D drives . I have STACK_ROOT = C:\sr . Other environment variables that might be of interest: see below.
  • I use Docker for windows. (no WSL2 enabled yet, because WSL2 requires at least Windows 10 version 2004. I have a company laptop, I am pushing them to upgrade, but without luck so far)

If you need any other info, let me know.

C:\Users\hjo20125>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\hjo20125\AppData\Roaming
ChocolateyInstall=C:\ProgramData\chocolatey
ChocolateyLastPathUpdate=132311620388961641
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=C7865606
ComSpec=C:\Windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
HOMEDRIVE=C:
HOMEPATH=\Users\hjo20125
LOCALAPPDATA=C:\Users\hjo20125\AppData\Local
LOGONSERVER=\\C7865606
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\hjo20125\OneDrive - Ordina
OneDriveCommercial=C:\Users\hjo20125\OneDrive - Ordina
OS=Windows_NT
Path=C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;D:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.242-3\bin;D:\Program Files\RedHat\java-1.8.0-openjdk-1.8.0.242-3\jre\bin;D:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;D:\Program Files\PostgreSQL\12\bin;D:\ffmpeg-4.2.3-win64-static\bin;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Users\hjo20125\.cargo\bin;C:\Users\hjo20125\AppData\Roaming\local\bin;C:\Users\hjo20125\AppData\Local\Microsoft\WindowsApps;C:\Users\hjo20125\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files (x86)\Graphviz2.38\bin\;C:\Program Files\Git\usr\bin\;C:\Users\hjo20125\AppData\Roaming\Composer\vendor\bin;C:\Users\hjo20125\AppData\Roaming\npm
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 9, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=9e09
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SNOW_AGENT=C:\Program Files (x86)\Snow Software\Inventory\Agent
STACK_ROOT=C:\sr
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\hjo20125\AppData\Local\Temp
TMP=C:\Users\hjo20125\AppData\Local\Temp
USERDNSDOMAIN=work.local
USERDOMAIN=WORK
USERDOMAIN_ROAMINGPROFILE=WORK
USERNAME=hjo20125
USERPROFILE=C:\Users\hjo20125
windir=C:\Windows

C:\Users\hjo20125>

src/Stack/Docker.hs Outdated Show resolved Hide resolved
@@ -340,6 +342,13 @@ runContainerAndExit = do
mountArg mountSuffix (Mount host container) =
["-v",host ++ ":" ++ container ++ mountSuffix]
sshRelDir = relDirDotSsh
toLinuxStylePath s | osIsWindows =
T.pack s
& T.replace ":\\" "/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right, it would convert c:\\foo into c/foo, for instance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will double check and then fix or try to convince you that this is the right thing to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Together with & addStartingSlashIfMissing (line 352) C:\\foo becomes /c/foo which is a legal and working thing. Maybe I could share some output from how this is working on my Windows machine to convince you that the folder sharing feature is working as expected?

As legal and working does not imply right I'm ready to discuss alternatives. I could mount/share the folders in /mnt/ (for our example /mnt/c/foo). What do you think about it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly can't figure out how all of that is supposed to work out correctly. As it stands now, this seems like it's trying to slyly address a bunch of edge cases, and I'm not convinced it's handling them correctly. It would be better to start off with what the expected behavior is for these edge cases, such as "c:\foo\bar" or relative paths like "foo\bar". It seems to me like these two cases are now in conflict.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right - it may be only working thanks to the fact that all paths happened to be absolute in my scenario. I will add explicit handling for absolute/relative paths and try to remove this hacky/sly smell around this change.

@gdziadkiewicz
Copy link
Contributor Author

@hanjoosten I will try to reproduce the problem and investigate.

@hanjoosten
Copy link

@hanjoosten I will try to reproduce the problem and investigate

Today I was lucky to be able to upgrade to windows 10, version 2004. So now I can use wsl2. I have been playing around with that now too. Still glad to test this change, if possible though. It could be very benificial to people using other windows builds.

@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from 5a509e3 to 2b18da4 Compare August 8, 2020 11:54
@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from ba0b2e8 to 79d1c0a Compare August 29, 2020 13:48
@gdziadkiewicz gdziadkiewicz force-pushed the #2421_support_docker_integration_on_windows branch from 79d1c0a to 6af7918 Compare November 16, 2020 18:20
@gdziadkiewicz
Copy link
Contributor Author

Hi all, I am closing this as I fully switched to using Haskell via wsl2 and won't have capacity to complete that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Docker integration on Windows
4 participants