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

Allow paths as environment file names #94

Merged
merged 1 commit into from
Dec 3, 2021
Merged

Allow paths as environment file names #94

merged 1 commit into from
Dec 3, 2021

Conversation

fgaz
Copy link
Contributor

@fgaz fgaz commented Jul 1, 2021

Mirroring the behaviour of ghc and cabal install --lib

"foo" -> $ghcEnvDir/foo
"./" -> $pwd/.ghc.environment.$ghcPlarform-$ghcVersion
"./foo" where foo is not a directory -> $pwd/foo

Closes #17

Mirroring the behaviour of ghc and cabal install --lib

"foo" -> $ghcEnvDir/foo
"./" -> $pwd/.ghc.environment.$ghcPlarform-$ghcVersion
"./foo" where foo is not a directory -> $pwd/foo

Closes #17
@fgaz fgaz marked this pull request as ready for review July 1, 2021 19:52
-- "./foo" where foo is not a directory -> $pwd/foo
getEnvPath :: Opts -> GhcInfo -> Peu r (Path Absolute)
getEnvPath Opts { optEnvName } ghcInfo =
if FP.takeBaseName optEnvName == optEnvName
Copy link
Contributor Author

@fgaz fgaz Jul 1, 2021

Choose a reason for hiding this comment

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

this is how we check for path-likeness in cabal, but I'm not sure it's the best way to do it

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, I don't like this either. I think picking some format (e.g. alphanumeric + -_) to be environment names, and everything else interpreted as paths would be better.

I'm not sure. I'll think some more and do the changes myself. Bear with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there anything I can do to help with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ping :)

@fgaz
Copy link
Contributor Author

fgaz commented Jul 14, 2021

Ping :)

I also think it could be a good idea to make . the default environment, maybe with a --default/--global flag that is sugar for --name=default

@phadej
Copy link
Owner

phadej commented Jul 20, 2021

I also think it could be a good idea to make . the default environment,

I disagree.

@fgaz
Copy link
Contributor Author

fgaz commented Jul 20, 2021

Why? I found myself using local environments more often than global ones. There is a risk of littering the filesystem with them though...

@phadej
Copy link
Owner

phadej commented Jul 20, 2021

Why?

There is a reason why I made this tool outside of cabal-install to begin with: I can tweak it to my liking. I'm happy with how cabal-env works now. We can discuss about adding a config file, but the defaults is up to me to decide.

@fgaz
Copy link
Contributor Author

fgaz commented Jul 20, 2021

the defaults is up to me to decide

Sure, just wanted to know the reason since that'd apply to a cabal command too. Personal preference is valid of course!

@jneira
Copy link

jneira commented Sep 9, 2021

I also think it could be a good idea to make . the default environment, maybe with a --default/--global flag that is sugar for --name=default

But it has the risk of break the local project build if cabal env is executed in a stack/cabal project root dir.
I would force the definitive solution to be a named environment by default (with flags to switch to global/local), although it has the incovenient of passing the name to ghc(i). I guess you could put the name in the ghci start config file.

@fgaz
Copy link
Contributor Author

fgaz commented Sep 9, 2021

But it has the risk of break the local project build if cabal env is executed in a stack/cabal project root dir.

Build tools that provide their own environment/packagedb to ghc are supposed to override it though. In fact, I don't think environment files can break cabal builds. If stack does not reset the environment, i think that's a bug in stack since there could always be an user-generated one in the way.

I think the biggest issue is having hidden state in your filesystem.

Anyway I think this discussion should go in haskell/cabal#6481, since @phadej already decided for cabal-env

edit: okay... I didn't expect it but GHC_ENVIRONMENT=not-existing cabal build fails... maybe that should be fixed in cabal

@phadej phadej merged commit 34663e3 into phadej:master Dec 3, 2021
@fgaz fgaz deleted the env-file-path branch December 4, 2021 10:34
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.

cabal-env: Allow creating local .ghc.environment.* files.
3 participants