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

[WIP] Use the directory package to create new-install symlinks #5684

Closed
wants to merge 7 commits into from

Conversation

YellPika
Copy link

Running cabal new-install on Windows currently gives the error "Symlinking feature not available on Windows". Symlinks have been supported on Windows since Vista (with administrator privileges), and symlinks can currently be created without administrator privileges on Windows 10 when in developer mode. This change lets cabal new-install create symlinks on Windows.

I've been using this patch on my own Windows system for ~4 months (ever since haskell/directory#83 was fixed) with no issues.

One caveat is that directory-1.3.3.0 or newer is required for in order to create symlinks on Windows 10 without administrator privileges.


Please include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • If the change is docs-only, [ci skip] is used to avoid triggering the build bots.

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

This provides uniform code and behaviour across all platforms, including Windows.
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "d8bae5190107627a41eba4b33aa0041f4475c800",
"tag":"osx-8.0.2"
}
@23Skidoo
Copy link
Member

Sounds like a good idea.

haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 13, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "2a7e3b77f66b3e4cd9a5fe1504169ad907664f45",
"tag":"osx-7.8.4"
}
@@ -307,7 +307,7 @@ executable cabal
containers >= 0.5 && < 0.7,
cryptohash-sha256 >= 0.11 && < 0.12,
deepseq >= 1.3 && < 1.5,
directory >= 1.2.2.0 && < 1.4,
directory >= 1.3.3.0 && < 1.4,
Copy link
Member

@hvr hvr Nov 13, 2018

Choose a reason for hiding this comment

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

That's a fairly recent directory version (it only started getting bundled w/ GHC 8.6); can we make this conditional on if os(windows)?

Copy link
Author

Choose a reason for hiding this comment

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

I don't understand the problem. Are you worried about the stability of recent versions of directory?

This change uses the createFileLink function, which was added in directory-1.3.1.0, so the lower bound will need to be raised anyways. Is 1.3.1.0 an acceptable lower bound? One potential downside is that the behaviour of new-install on Windows will differ depending on which version of directory was used to compile cabal-install.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the concern is mostly support, does directory-1.3.1.0 support the same versions of GHC that cabal supports, if not it can't be unconditionally used.

This change uses the createFileLink function, which was added in directory-1.3.1.0, so the lower bound will need to be raised anyways. Is 1.3.1.0 an acceptable lower bound? One potential downside is that the behaviour of new-install on Windows will differ depending on which version of directory was used to compile cabal-install

This is quite normal, and just means the distro needs to be built with an up-to-date compiler/cabal. Long filenames support is another thing that already depends on which version of GHC is used.

Copy link
Member

Choose a reason for hiding this comment

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

Well, we have all those *.Compat.* modules for a reason... ;-)

See

So I'd strongly suggest to try to follow the prior-art from those compat modules to avoid requiring such a bleeding edge directory version

@YellPika
Copy link
Author

Travis is reporting that the bootstrap builds are failing. I tried having bootstrap.sh download the appropriate directory version, but this caused dependency conflicts. Any advice on how to resolve this issue?

Copy link
Collaborator

@Mistuke Mistuke left a comment

Choose a reason for hiding this comment

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

Implementation wise no objections from me, just a question, have you tested this on older versions of Windows or windows 10 with developer mode off? Just want to make sure that the errors propagated by the directory function are properly handled.

I assume since the old implementation threw an error as well, but just want to check that what is thrown now makes sense.

@YellPika
Copy link
Author

Before, any attempt to use new-install would report:

Symlinking feature not available on Windows

Running without developer mode now gives a failure message like the following:

C:\Users\Anthony\AppData\Roaming\local\bin\ghcid.exe: createFileLink:CreateSymbolicLink:
permission denied (A required privilege is not held by the client. Creating symbolic links
usually requires administrative rights.)

I don't have any machines with older versions of Windows, so unfortunately I can't test there.

haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"osx-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "01f193a92e284a59a089e335eba8eddc42f7089c",
"tag":"osx-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-7.10.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-8.0.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-7.8.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-8.2.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-7.6.3"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-8.4.4"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-8.6.2"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"linux-8.4.4-fdebug-expensive-assertions"
}
haskell-pushbot pushed a commit to haskell-pushbot/cabal-binaries that referenced this pull request Nov 14, 2018
"url":"pull/5684",
"account":"haskell",
"repo":"cabal",
"commit": "cf67537c54a675be16ca21eba637fb9272a267cf",
"tag":"osx-7.8.4"
}
@Mistuke
Copy link
Collaborator

Mistuke commented Nov 14, 2018

Yeah that error looks fine to me. No objections from my part. I'll leave it to @hvr about the directory bounds

@23Skidoo
Copy link
Member

An alternative solution/fallback would be to copy and record the checksum of the installed exe somewhere, and after that overwrite only if the checksum of the existing file matches the recorded one (or the user forced an overwrite explicitly).

@veqryn
Copy link

veqryn commented Apr 26, 2020

I'm brand new to haskell and trying to setup my dev environment on windows. Immediately ran into the error message that Symlinking feature not available on Windows, despite that being false.
Any chance this PR can get traction again?

@phadej
Copy link
Collaborator

phadej commented Apr 26, 2020

Symlinking on windows is done in #6519, but it looks it doesn't made it into 3.2. Will be in the next major cabal-install

@phadej phadej closed this Apr 26, 2020
@phadej phadej mentioned this pull request Jul 10, 2020
@phadej phadej added this to the 3.4.0.0-rc1 milestone Jul 13, 2020
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.

None yet

6 participants